2011-12-01 28 views
0

我正在使用Apple的一些示例代码为我的应用程序编写Twitter集成。Twitter集成和iOS5:语义和解析问题

但是,我收到了大量的错误(主要是语义和解析错误)。

这怎么解决?

-(IBAction)TWButton:(id)sender { 
ACAccountStore *accountstore = [[ACAccountStore alloc] init]; 
//Make sure to retrive twitter accounts 
ACAccountType *accountType = [accountstore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; 
[accountstore requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error) { 
    if (granted) [{ 
     NSArray *accountsArray = [accountstore accountsWithAccountType:accountType]; 
    if ([accountsArray count] > 0) { 
ACAccount *twitterAccount = [accountsArray objectAtIndex:0]; 

      TWRequest *postRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:@"http://api.twitter.com/1/statuses/update.json"] parameters:[NSDictionary dictionaryWithObject:[@"Tweeted from iBrowser" forKey:@"status"] requestMethod:TWRequestMethodPOST]; 

      [postRequest setAccount:twitterAccount]; 

      [postRequest preformRequestWithHandeler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { 
       NSString *output = [NSString stringWithFormat:@"HTTP response status: %i", [urlResponse statusCode]]; 
       [self preformSelectorOnMainThread:@selector(displaytext:) withObject:output waitUntilDone:NO]; 
      }]; 

     } 
    }]; 
} 
//Now lets see if we can actually tweet 

-(void)canTweetStatus { 
    if ([TWTweetComposeViewController canSendTweet]) { 
     self.TWButton.enabled = YES 
     self.TWButton.alpha = 1.0f; 
    }else{ 
     self.TWButton.enabled = NO 
     self.TWButton.alpha = 0.5f; 
    } 



} 

enter image description here

+1

如果不是使用屏幕截图,而是使用日志中的实际文字,它可能会更好。 – ThomasW

回答

0

我看到的第一个错误是很容易摆脱。

Objective C约定是将每个方法名的首字母缩写为小写。

使用makeKeyAndVisible在AppDelegate.m

我们可能就需要看到(在代码中)被抛出的错误其他错误,不只是什么样的错误。

+0

@Micheal谢谢你,但我仍然收到错误“makeKeyAndVisible在'AppDelegate'类型的对象上找不到'”,并且为了更好地查看错误,可以在以下网址找到它们:yfrog.com/klvqxrp – Tyler

+0

错误行'if(granted){'(移除[括号] –

+0

@Micheal谢谢:),你对其他错误有什么建议吗? – Tyler