Friday, 15 June 2018

Using Clousers in Swift

Hello guys in this tutorial I am going to tell you about Clousers.

Clousers are used as an alternative to functions. 

According to Apple , Clousers are self contained blocks of functionality that can be passed around or used in the code. 

Syntax for Clousers in Swift

              Syntax ==  {(parameters) -> (returnType) in }

Here is an example for Clousers : 

Here var clouserExample is the declaration of the clouser
and print is its usage. 

Difference between functions and Clousers : 

Most of the people ask what is the difference between functions and Clousers. Although they offer almost the same purpose but here are some of the key points : 

  • has a name 
  • has func keyword
  • has no in keyword

  • has no name
  • has no func keyword
  • has in keyword

And that's it. Hope you have enjoyed the blog !
Thanks :)

Tuesday, 6 September 2016

JSON parsing using GET method in AFNetworking

In this tutorial I will use AFNetworking  to parse JSON data in our iOS application .

For JSON parsing ,  i will use GET method.

So lets move straight to code.

1. Add AFNetworking to your project .

Install pods of AFNetworking or directly add them to your project

2. Don't forget to add AFNetworking.h to your view controller.

#import "AFNetworking.h"

3. Finally add this code to parse JSON data using Get method

Thats it .

For more blogs on JSON parsing visit my another blog

Keep reading  :)

Sunday, 17 July 2016

Get user data from Facebook in iOS

In this tutorial I will tell you about fetching user information from Facebook in your application.


First of all you need to integrate Facebook SDK to your project .

For integrating Facebook to your project click on the link  . Facebook provides simple iOS SDK integration .

After integrating Facebook to your project :

1)  Create  a UIButton for login with facebook

2) Login Facebook on button's action and add Facebook details method to get user details

By Facebook details method :-
You can get
1) Social id
2) Full name of user
3) Email of user
4) Profile picture

For uploading image file to server , please visit my blog on image uploading using multipart 

Thanks :) 

Friday, 20 May 2016

Change UISegmentControl color in iOS

How to change color of UISegmentControl in iOS  ?

 To change UISegmentController color add the following code in your viewDidLoad  : 


Cheers !

Happy Coding :)

Monday, 18 April 2016

JSON parsing using GET method in iOS

In this post , we will know about how to send or receive JSON data using GET parameters .

Step 1 : Create a new Xcode project .

Step 2:   Update info.plist in your project.

1)    Add App Transport Security Settings in the plist .

2)    Add Allow Arbitrary Loads to YES as a subtype of App Transport Security Settings.

Step 3 : Add the following code in ViewDidLoad

For JSON parsing using post parameters view my post on JSON using POST parameters 

Thank You :)

Thursday, 14 April 2016

Upload image file to server in iOS.

In this tutorial we will upload the image as a file to JSON server .
For uploading image as a file we use multipart form as our content type .

Now jumping straightforward to our code .

Step 1 :  Add AFNetworking framework to your project .

               How to add AFNetworking to your project ?
               Visit my previous post on AFNetworking .

Step 2:   Import AFNetworking to your project.

             #import <AFNetworking/AFNetworking.h>

Step 3:   Add the following code in viewDidLoad to upload image as a file :

Thats all about file uploading in iOS .

Thank you :) .

Monday, 11 April 2016

JSON parsing with POST parameters using AFNetworking 3.0

Step 1 : Search AFNetworking in github and install the AFNetworking in your project through cocoa pods .

  1.  Go to terminal .
  2.  Open your folder where you have created your project by simply writing cd location of your project. e.g.: cd /Users/SaurabhPc/Desktop/Saurabh 
  3.  Write pod init 
  4. After that write open -a Xcode Podfile in the terminal . This command will open projects pod file .
  5. Add the following command to add AFNewtorking pod to the project

pod 'AFNetworking', '~> 3.0'

    6.  write pod install to install the pod

After few minutes the pod will be added to your project

Step 2 : Open your project using workspace.
  1.  #import <AFNetworking/AFNetworking.h> in your project.
  2. Now add the code to your viewDidLoad to hit web service.

For more post on AFNewtorking visit JSON parsing using AFNetworking

Thankyou :)