Интеграция с Twitter и iOS5: проблемы семантики и парсинга - PullRequest
0 голосов
/ 01 декабря 2011

Я использовал пример кода Apple для написания интеграции Twitter для моего приложения.

Однако я получаю колоссальное количество ошибок (в основном это семантические ошибки и ошибки разбора).

Как это можно решить?

  -(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 Ответ

0 голосов
/ 01 декабря 2011

От первой ошибки, которую я вижу, легко избавиться.

Цель соглашения C состоит в том, чтобы сделать первые буквы каждого имени метода строчными.

Используйте makeKeyAndVisible в вашем AppDelegate.m

Другие ошибки, которые мы, вероятно, должны были бы увидеть, где (в вашем коде) выбрасываются ошибки, а не только какие ошибки.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...