title: Right way to handle user session with IOS NSURLSession
body: <p>Hi I am beginner to IOS development. I am developing small IOS application. Required functionality of that application is like this. Application have login for user. once your logged in it will not ask for login again until user do logout. I completed login part. I done with login using NSURLSession.Now after login I want to fetch some thing from server but it is giving error with status code 0 or 1012. I don't know why it is giving this error. So my questions are like this </p>
  
  <p>How NSURLConnection works? </p>
  
  <p>Is it taking care of session for user or I have to take care of that? </p>
  
  <p>After login process I am not able to do anything, mostly because of unauthorised access. I did login in following way </p>
  
  <pre><code>  NSURLSession *session = [NSURLSession sharedSession];
  [[session dataTaskWithURL:url completionHandler:
    ^(NSData *data, NSURLResponse *response, NSError *error)
    {
        NSHTTPURLResponse *httpResp = (NSHTTPURLResponse*) response;
        NSLog(@"sttaus code %i", httpResp.statusCode);
        if(error)
       {
          [self.delegate signinWithError:error];
       }
       else
       {
          [self.delegate signinWithJson:data];
       }
    }] resume];
  </code></pre>
  
  <p>I have to set NSURLSession globally or I can use it locally as well? </p>
  
  <p>Is there any one have good explanation about it? Any good example ? Need Help. Thank you. </p>