2014-10-09 62 views
-8

我複製的代碼來自Facebook的開發者網站整合Facebook分享到我的應用程序時,「程序意外@」:複製Facebook的股票代碼

NSMutableDictionary<FBGraphObject> *object = [FBGraphObject openGraphObjectForPostWithType:@whatsyourinneragefb:inner_age 
             title:@Sample Inner Age 
             image:@https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png 
              url:@http://samples.ogp.me/578838518886846 
            description:@];; 

[FBRequestConnection startForPostWithGraphPath:@"me/objects/whatsyourinneragefb:inner_age" 
            graphObject:object 
          completionHandler:^(FBRequestConnection *connection, 
               id result, 
               NSError *error) { 
           // handle the result 
          }]; 

然而,「@」 @whatsyourinneragefb之前產生錯誤"Unexpected @ in program。此外,像@https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png這樣的行擁有@https:白色,其餘部分突出顯示爲綠色,就像它是一條評論,所以即使上述錯誤消失,我也覺得這樣做不起作用。所以:

我該如何解決第一個錯誤?

是代碼的功能,或是否需要進行調整的工作?

所有幫助表示讚賞。

+0

您從哪裏複製它? – WizKid 2014-10-09 19:47:51

+4

我強烈建議您在提問這樣​​的問題之前,先閱讀*至少* Objective-C語言的基礎知識。我建議閱讀以下內容:http://stackoverflow.com/help/how-to-ask – 2014-10-09 19:50:15

+0

我在Facebook開發人員網站的「我的應用程序」中訪問了我的應用程序,然後轉到Open Graph,然後單擊「獲取代碼」。 – 2014-10-09 19:50:49

回答

3

Objective-C中的字符串文字看起來像@"this"。例如,可以將@Sample Inner Age改變爲@"Sample Inner Age"

+0

我會爲「inner_age」做這個嗎?這現在產生錯誤「使用未聲明的標識符'內在時代'」 – 2014-10-09 19:47:34

+0

是的,像'@「whatsyourinneragefb:inner_age」'。 – 2014-10-09 19:50:14

+3

@IsaacA RTFM ..? – displayname 2014-10-09 19:55:26

0

我不確定您從哪裏複製了該代碼;我無法在Facebook開發者網站上找到任何關於「內心時代」的提及。你可能誤解了你如何編輯他們提供的源代碼。使用注入數據的正確實現將爲字符串文本提供帶引號的引號(您還缺少說明):

NSMutableDictionary<FBGraphObject> *object = [FBGraphObject openGraphObjectForPostWithType:@"whatsyourinneragefb:inner_age" 
            title:@"Sample Inner Age" 
            image:@"https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png" 
             url:@"http://samples.ogp.me/578838518886846" 
           description:@"<you're missing a description>"]; 

[FBRequestConnection startForPostWithGraphPath:@"me/objects/whatsyourinneragefb:inner_age" 
           graphObject:object 
         completionHandler:^(FBRequestConnection *connection, 
              id result, 
              NSError *error) { 
          // handle the result 
         }];