Friday, 8 November 2013

Reachability Class For iOS

Hello Friends,

                      I have attached Reachability Class to check the network. This class can check either your internet connection is available or not . You can download the SDK of Reachability Class from here  :-

 https://github.com/preetlotey999/Reachability-Class-For-iOS.git


After download you can drag & drop this SDK to your project & make sure you tick the following things show in the screen shot :-



Import Reachability Class in your class then write this code in your viewDidLoad method :-

- (void) viewDidLoad
{
    [super viewDidLoad];

    Reachability *reachability = [Reachability reachabilityForInternetConnection];
    
    NetworkStatus internetStatus = [reachability currentReachabilityStatus];
    
    if (internetStatus != NotReachable)

    {
                // Write your code here.
    }

    else
     {
              UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Reachability" message:@"Please check your internet connection." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        
        [alert show];
     }
}

Below is the screen shot :-



For arc enabled project do this :-



Thanks Guys. If you like the code then post a comment & if you have any query regarding this code or you have any query then post your query on this Blog.  :)

Log In with Facebook & Share Application With Simple Way For iOS.

For Facebook login , you should do 3 things :-
1. Using Singleton, Why?
Singleton allow you to access same variable or method in different page , since you will use Facebook class in their view , so start using singleton.
2. Core Part – Facebook iOS Class.
3. Delegate.
Facebook use delegate to do callback , as singleton is suggested to use , so we need to set up our own delegate for the views that are using access Facebook.

1. Firstly you create a new project  select Single View Application

2. Click next write name of the project For eg :- FacebookLogIn then click next 

3. Select path where you want to create the app & click Create.

4. Now first download Facebook SDK from here :-
https://github.com/preetlotey999/Download-Facebook-SDK-For-iOS
5. Drag & drop the SDK into your project. Make sure tick these options as shown below in the screen shot.

6. Now open your storyboard or xib drag & drop UIButton named Facebook Log In 

7. Create action of FBLogIn Button :-

8. Now give action to file owner 

9. Now write the code in UIButton action :-

10. Now set up APP ID of Facebook in Singleton.m 

11. Now this APP ID also set in info.plist :-

12. Now to handle the Facebook write this code in AppDelegate :-

For arc enabled project do this :-


Now Run The Code & Click On FB Button.
It will first open the session enter your Facebook username & password then login & share the application.

You can also download full code project from here :-

https://github.com/preetlotey999/Facebook-Log-In-and-Share-Application-For-iOS.git
Thanks Guys. If you like the code then post a comment & if you have any query regarding this code or you have any query then post your query on this Blog.  :)