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.
精彩评论