开发者

Parameters in output in selector, objective c

i'm executing a method in background, by @selector(method) but i dont' understand how can i return data, for example if method name is:

-(int)methodWithAge:(int)age
开发者_开发知识库

i make:

int a = [self performBackgroundThread @selector(methodWithAge:) WithObjects:myAge];

but it doesn't work.

Thanks for any help.


I guess you shuold use NSNumber instead of int

-(int)methodWithAge:(NSNumber*) age

And convert int to NSNumber

NSNumber* num = [NSNumber numberWithInt:age];
int a = [self performBackgroundThread @selector(methodWithAge:) WithObjects:num];


Not using it right. Whats your exact error? I don't know any backin method called performBackgroundThread. You have to pass your values pack to the main thread. Read this tutorial on this topic.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜