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.