开发者

Parameters in output in selector, objective c

开发者 https://www.devze.com 2023-03-07 17:05 出处:网络
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:

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

精彩评论

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