小编ale*_*ssa的帖子

如何在objective-c中将方法设置为类方法的参数

我在编写一个有方法有参数的类方法时遇到了问题.

该函数在"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];
    }
}
Run Code Online (Sandbox Code Playgroud)

该函数的作用是调用JSON url,并将数据提供给Method

我这样使用它:

[SystemClass callLink:@"http://www.mywebsite.com/call.php" toFunction:@selector(fetchedInfo:) withVars:nil];
Run Code Online (Sandbox Code Playgroud)

但它像这样崩溃:

因未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'+ [SystemClass方法:]:无法识别的选择器发送到类0x92d50'

你可以帮帮我吗?无论如何,我正试图找到解决方案!

谢谢,亚历克斯

iphone methods class ios

5
推荐指数
1
解决办法
193
查看次数

标签 统计

class ×1

ios ×1

iphone ×1

methods ×1