2013-06-25 20 views
0

嗨,大家好,我知道這種說法是被共享已經我得到了應用程序破碎時,我嘗試使用此代碼:無法識別的選擇發送到實例 - Facebook的

if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]){ 

    SLComposeViewController *facebook = [SLComposeViewController 
                composeViewControllerForServiceType:SLServiceTypeFacebook]; 



    [facebook setInitialText:@"https://itunes.apple.com"]; 
    [self presentViewController:facebook animated:YES completion:Nil]; 

    [facebook setCompletionHandler:^(SLComposeViewControllerResult result) { 
     NSString *outPut = nil; 

     switch (result) { 
      case SLComposeViewControllerResultCancelled: 
       outPut [email protected]"Action Cancelled"; 
       break; 
      case SLComposeViewControllerResultDone: 
       outPut = @"Posted Successfully"; 
       break; 
      default: 
       break; 

}

 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Facebook" message:outPut delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil, nil]; 
     [alert show]; 



    }]; 

} 

以下是我的崩潰報告:

2013-06-25 12:41:24.112 MyApp[11779:1cd03] -[AboutViewController Facebook:]: unrecognized selector sent to instance 0x9c649d0 
2013-06-25 12:41:24.114 MyApp[11779:1cd03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AboutViewController Facebook:]: unrecognized selector sent to instance 0x9c649d0' 
*** First throw call stack: 
(0x1a67012 0x12d3e7e 0x1af24bd 0x1a56bbc 0x1a5694e 0x12e7705 0x21b2c0 0x21b258 0x2dc021 0x2dc57f 0x2db6e8 0x24acef 0x24af02 0x228d4a 0x21a698 0x2ba0df9 0x2ba0ad0 0x19dcbf5 0x19dc962 0x1a0dbb6 0x1a0cf44 0x1a0ce1b 0x2b9f7e3 0x2b9f668 0x217ffc 0x2afd 0x2a25) 
libc++abi.dylib: terminate called throwing an exception 
(lldb) 

同樣發人深省的碰撞,它會自動給我的主頁上顯示我此行

return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 
signal SIGBART 

我想說的,以及我在編程新的,可能你都會發現錯誤各位是簡單識別。 如果你們中的一些人會與我分享你的知識並幫助我找到崩潰的解決方案,我們將非常感激。

在此先感謝!

回答

1

看來你的AboutViewController沒有在你的.h文件中定義的Facebook:方法。 用冒號仔細查看它的Facebook:。這意味着你的方法應該有一個參數。

希望這會有所幫助。

提示:每當你有unrecognized selector在你的應用程序崩潰。這意味着你的方法沒有在你的課堂上定義或不可用。請記住,私有方法不能通過類對象訪問。

瞭解更多關於私人方法在這裏。 Best way to define private methods for a class in Objective-C

BTW,歡迎計算器:)

+0

嗨iNeal, 看來你正確的地方,而且我不明白爲什麼即使在我的類定義它不能識別方法。 任何未來的方式和與他人分享我只是打開一箇舊的應用程序保存版本,並從頭開始重寫代碼,它的工作。 感謝您的寶貴幫助,並給我一個歡迎。 謝謝!!!! –

相關問題