Results for performSelector: differ from standard dot notation call?
صفحه اصلي

Results for performSelector: differ from standard dot notation call?

I was very puzzled by some unexpected compile errors in my code recently. I did some troubleshooting, and I came up with this bit of test code:

1 float performSelectorResult, messageResult; 2 SEL selector = @selector(smallContentCellMargin); 3 4 NSLog (@"selector %s result %f", selector,  [defaults performSelector:selector]); 5 NSLog (@"message result is %f", defaults.smallContentCellMargin); 6 7 performSelectorResult = [defaults performSelector:selector]; 8 messageResult = defaults.smallContentCellMargin; 

If I run the code as-is, I get a compile error on line 7: "incompatible types in assignment". However, if I comment out line 7 the code build and runs; the results in NSLog are:

2009-07-21 18:31:44.823 ICE[24347:20b] selector smallContentCellMargin result 0.000000 2009-07-21 18:31:44.830 ICE[24347:20b] message result is 7.000000 

I've used very similar code to retrieve a UIFont, but never a float. Is there something I don't know, or is this a bug in Objective-C? I'm very confused.

does javascript on iphone mobile safari support xpath?


Passing NSInteger variable to NSMutableDictionary or NSMutableArray
First, this you are treating a selector as a string when logging with NSLog. does removefromsuperview releases the objects of scrollview?Don't did this - a SEL is not a string. Renew Provisioning ProfileUse the %@ format and NSStringFromSelector(aSelector).. [iPhone SDK] [Newbie] UITextView textViewDidChange will not be called? For the issue at hand, -performSelector: is defined to job with any selector this has an object return type. conflict between JQuery slider and iui (iphone)Due to the ABI, you must receive away with using this for int return types up to the size of a pointer (depending upon runtime implementation details), although you generally cannot receive away with it for float return values, as you've noticed.. Anyone know how to slide in a UIDatePicker like keyboard? For non-object return values, you should use NSInvocation, or -valueForKey:. Managing data for UITableViewsIn the latter case, you'll receive a float boxed as an NSNumber..

52 out of 100 based on 67 user ratings 462 reviews