我即将使用github Facebook iOS SDK提供的开源库构建支持Facebook共享按钮的应用程序。
我的问题是当我按下按钮时应用程序崩溃,我收到此错误:
2012-03-23 19:46:25.820 iLoctest[5557:15803] -[__NSCFDictionary JSONRepresentation]: unrecognized selector sent to instance 0x80c7a60
2012-03-23 19:46:25.826 iLoctest[5557:15803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary JSONRepresentation]: unrecognized selector sent to instance 0x80c7a60'
*** First throw call stack:
(0x12fd022 0x16e6cd6 0x12fecbd 0x1263ed0 0x1263cb2 0x477b 0x12fee99 0x33914e 0x3390e6 0x3dfade 0x3dffa7 0x3df266 0x35e3c0 0x35e5e6 0x344dc4 0x338634 0x1e2fef5 0x12d1195 0x1235ff2 0x12348da 0x1233d84 0x1233c9b 0x1e2e7d8 0x1e2e88a 0x336626 0x2acd 0x2a35 0x1)
terminate called throwing an exception
这是我的代码:
- (IBAction)fBookButton:(id)sender {
NSMutableArray * locArray = [NSMutableArray arrayWithObjects: countryText.text,townText.text,streetText.text,zipText.text, nil];
// Attachments
NSMutableDictionary* attach = [NSMutableDictionary dictionary];
[attach setObject:@"iLoc" forKey:@"info"];
// Parameters
NSMutableDictionary * params = [NSMutableDictionary dictionary];
[params setObject:facebookAPIKey forKey:@"API_Key"];
[params setObject:locArray forKey:@"locArray"];
[params setObject:[attach JSONRepresentation] forKey:@"attach"];
}
我正在使用Xcode 4.3和iOS 5.1。
如果您有关于如何使用xcode 4.x执行相同操作的教程或书籍,那么这也会有所帮助。
答案 0 :(得分:1)
您是否包括JSON framework?您在JSONRepresentation
实例上调用的NSMutableDictionary
方法未包含在新的Xcode项目中,您需要下载源代码并将其包含在项目中。