iPhone performSelector changes object type
I 开发者_如何学Gohave a callback class with the method -(void)fire
and it calls
[target performSelector:selector withObject:dictionary];
Just before that line I added NSLog(@"%@", [[dictionary class] description]);
to see where the object changed, when debugging it returns NSCFDictionary.
So that was all fine. Next I went and added a similar line to get the arguments type inside the method being called. Now, when debugging, it returns NSCFString, whilst the callback logs NSCFDictionary.
Is there any reason why this object is becoming an NSString once I call performSelector?
You can only pass one argument to your method if you use performSelector:withObject:.
Check out performSelector:withObject:withObject: or use NSInvocation.
精彩评论