我正在使用 FB SDK 允许用户邀请朋友下载我的应用程序。当用户单击邀请按钮时,我正在创建一个 FB 请求。动作如下所示:
- (IBAction)inviteButtonPressed:(UIButton *)sender {
// create a dictionary for our dialog's parameters
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity: 7];
// set the frictionless requests parameter to "1"
[params setObject: @"1" forKey:@"frictionless"];
[params setObject: @"Test Invite" forKey:@"title"];
[params setObject:appID forKey:@"app_id"];
[params setObject: @"Test" forKey: @"message"];
if([friendsToInvite count] != 0){
[params setObject:friendsToInvite forKey:@"to"];
NSLog(@"%@", params);
}
// show the request dialog
[facebook dialog:@"apprequests" andParams:params andDelegate: nil];
}
问题是我正在为@“to”属性的对象传递一组朋友(由用户选择)。这就是 Facebook 库尝试解析 @"to" 对象的方式(来自 Facebook 的代码):
id fbid = [params objectForKey:@"to"];
if (fbid != nil) {
// if value parses as a json array expression get the list that way
SBJsonParser *parser = [[[SBJsonParser alloc] init] autorelease];
id fbids = [parser objectWithString:fbid];
if (![fbids isKindOfClass:[NSArray class]]) {
// otherwise seperate by commas (handles the singleton case too)
fbids = [fbid componentsSeparatedByString:@","];
}
invisible = [self isFrictionlessEnabledForRecipients:fbids];
}
我的代码给了我这个错误:
-[__NSArrayM UTF8String]: unrecognized selector sent to instance 0x1aea00
2012-05-08 01:48:29.958 shmob[2976:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM UTF8String]: unrecognized selector sent to instance 0x1aea00'
当我将单个应用程序 ID 硬编码到 @"to" 对象中时,它可以工作!你知道如何邀请 Facebook 好友列表吗?