title: post status on facebook
body: <p>I am implementing an app in which user will be able to post status. If user is default login in his/her device then following code will work </p>
  
  <pre><code>  if(!self.accountStore)
      self.accountStore = [[ACAccountStore alloc] init];
  if(NSClassFromString(@"SLComposeViewController") != nil)
  {
      ACAccountType *facebookTypeAccount = [self.accountStore 
      accountTypeWithAccountTypeIdentifier:@"com.apple.facebook"];
      NSLog(@"facebookTypeAccount..:%@",facebookTypeAccount);
      NSArray *accounts = [self.accountStore accountsWithAccountType:facebookTypeAccount];
      if (facebookTypeAccount) {
          if ([accounts respondsToSelector:@selector(count)]) {
              [self.accountStore requestAccessToAccountsWithType:facebookTypeAccount
                                                         options:@{ACFacebookAppIdKey: @"214267482030378", ACFacebookPermissionsKey: @[@"email"]}
                                                      completion:^(BOOL granted, NSError *error) {
                                                          if(granted){
                                                              NSArray *accounts = [self.accountStore accountsWithAccountType:facebookTypeAccount];
                                                              _facebookAccount = [[accounts lastObject]retain];
                                                          }
                                                          else
                                                          {
                                                              NSLog(@"Failed, Error: %@", error);
                                                          }
                                                      }];
          }
          else
          {
              [self openSession];
          }
      }
  } 
  </code></pre>
  
  <p>Otherwise control will go to this method</p>
  
  <pre><code>- (void)openSession{
  NSArray *permissions = [[NSArray alloc] initWithObjects:
                          @"publish_stream",@"email",
                          nil];
  [FBSession openActiveSessionWithPublishPermissions:permissions
                                     defaultAudience:FBSessionDefaultAudienceEveryone
                                        allowLoginUI:YES
                                   completionHandler:^(FBSession *session, FBSessionState state, NSError *error)
   {
       [self sessionStateChanged:session state:state error:error];
  
   }];
  </code></pre>
  
  <p>}</p>
  
  <p>But with login I need to send status on Facebook. If I tried with this method </p>
  
  <pre><code>   -(void)poststatus{
  [[FBSession activeSession] reauthorizeWithPublishPermissions:@[ @"publish_stream" ]  
  defaultAudience:FBSessionDefaultAudienceEveryone completionHandler:^(FBSession 
  *authSession, NSError *authError) {
      // If auth was successful, create a status update FBRequest
      if (!authError) {
          FBRequest *postRequest = [FBRequest requestForPostStatusUpdate:@"Hello, world!"];
          [postRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
              // TODO: Check for success / failure here
          }];
      }
  }];
  </code></pre>
  
  <p>}</p>
  
  <p>then it gives the error Failed, Error: Error Domain=com.apple.accounts Code=8 "The operation couldn’t be completed. (com.apple.accounts error 8.)" Please help me out if anyone has some idea regarding this concept.</p>
  
  <p>Thanks in advance.</p>