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.


Facebook



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  : 





Result





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 :)



Wednesday, 30 March 2016

Blocks in Objective c

Blocks are Objective c`s anonymous functions . 

Block is a self-contained, autonomous code fragment, existing always in the scope of another programming structure , e.g. body of a method.


Blocks helps you to :
1)  Reduce code
2)  Write more cleaner code
3)  More reliable code

Block basic syntax : 

                        ReturnType (^Name of the block) (Parameters)

  • ReturnType : Any datatype supported by Objective c 

  • ^Name of the block : Name of the block is always preceded by the carret symbol (^).

  • Parameters : Parameters which you want to pass on the block.



Block example : 





Blocks used for array enumeration  :


Arrays enumeration using blocks is fastest .

>> Use this code for faster enumeration of arrays



Blocks Advantages:


1) Blocks can do same as methods but methods can`t do all the tasks like blocks

2) Blocks can be parsed to other functions.

3) Blocks are used in multi-threading

4) Blocks have faster array enumeration as compared to for in and for loops .

5) Blocks are simpler to read.


That`s a small introduction to blocks in objective c. More complex part will be covered in the future tutorials .



Thank you :)