【发布时间】:2012-10-15 14:37:10
【问题描述】:
我在编写一个类方法时遇到问题,它有一个方法有参数。
函数在类“SystemClass.m/h”中
//JSON CALL
+(void)callLink:(NSString*)url toFunction:(SEL)method withVars:(NSMutableArray*)arguments {
if([self checkConnection])
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSData *datas = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]];
[arguments addObject:datas];
[self performSelectorOnMainThread:@selector(method:) withObject:arguments waitUntilDone:YES];
});
}else{
[self alertThis:@"There is no connection" with:nil];
}
}
该函数的作用是调用一个 JSON url,并将数据提供给一个方法
我是这样使用的:
[SystemClass callLink:@"http://www.mywebsite.com/call.php" toFunction:@selector(fetchedInfo:) withVars:nil];
但它会像这样崩溃:
由于未捕获的异常而终止应用程序 'NSInvalidArgumentException',原因:'+[SystemClass 方法:]: 无法识别的选择器发送到类 0x92d50'
你能帮帮我吗?无论如何,我正在努力寻找解决方案!
谢谢,亚历克斯
【问题讨论】:
-
这与 Xcode 无关。重新标记。
-
现在更好的解决方案是使用块而不是选择器、目标和参数