2014-10-09 80 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 
         }];