2011-12-29 5 views
1

** Twitter.framework 및 Accounts.framework를 추가했습니다.iOS 5.0의 Twitter 통합

그리고 Twitter.h 헤더 파일을 가져 왔습니다.

하지만 ** 오류 "선언되지 않은 식별자 'tweetSheet'의 사용"을 얻고있다

Class TWTweetComposeViewController = NSClassFromString(@"TWTweetComposeViewController"); 
if(TWTweetComposeViewController != nil) { 



    //For iOS 5.0 onwards 
    if ([TWTweetComposeViewController canSendTweet]) { 
     //Create the tweet sheet 
     TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init]; 

     //Customize the tweet sheet here 
     //Add a tweet message 
     [tweetSheet setInitialText:[[self getShareContent] objectForKey:@"twitterContent"]]; 

     //Set a blocking handler for the tweet sheet 
     tweetSheet.completionHandler = ^(TWTweetComposeViewControllerResult result){ 
      if (TWTweetComposeViewControllerResultDone) { 
           UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Tweeted" 
                        message:@"You successfully tweeted" 
                        delegate:self cancelButtonTitle:@"OK" 
                      otherButtonTitles:nil]; 
           [alertView show]; 
           [alertView release]; 
      } else if (TWTweetComposeViewControllerResultCancelled) { 
           UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Ooops..." 
                        message:@"Something went wrong, try again later" 
                        delegate:self 
                      cancelButtonTitle:@"OK" 
                      otherButtonTitles:nil]; 
           [alertView show]; 
           [alertView release]; 
      } 

      [self dismissModalViewControllerAnimated:YES]; 
     }; 

     //Show the tweet sheet! 
     [self presentModalViewController:tweetSheet animated:YES]; 

    } else { 

      UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil 
                   message:@"You need to configure your Twitter account in the Settings" 
                   delegate:self cancelButtonTitle:@"OK" 
                 otherButtonTitles:nil]; 
      [alertView show]; 
      [alertView release]; 


    } 

} 
+0

[여기] (http://dummycode.com/b/3)는 Twitter API와 iOS를 통합 한 훌륭한 글입니다. –

답변

1

당신은 클래스와 같은 이름을 가진 변수 (TWTweetComposeViewController)를 만든 때문에 컴파일러는 혼란 이름. 처음 두 줄을 다음으로 변경하십시오.

Class tweetComposeViewController = NSClassFromString(@"TWTweetComposeViewController"); 
if(tweetComposeViewController != nil) { 

... 모두 좋을 것입니다.