dot notation doesn’t work as expected for some library classes
dot notation doesn’t work as expected for some library classes
- Subject: dot notation doesn’t work as expected for some library classes
- From: Marc Liyanage <email@hidden>
- Date: Mon, 25 May 2009 00:00:20 +0200
I was playing around a bit with the Obj-C 2.0 dot notation to clarify
some things for me. In my own classes getters and setters are called
as expected, but I noticed several times already that library classes
sometimes don’t allow the dot notation (that’s the reason why I’m
trying to clarify this in the first place).
I’m wondering why this example with NSMutableString does not compile:
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSMutableString *xyz = [NSMutableString string];
xyz.string = @"foo";
[pool drain];
return 0;
}
This fails to build with the message "error: request for member
'string' in something not a structure or union". That message is
expected when there is no such accessor, but it does compile when I
replace the dot notation accessor with this:
[xyz setString:@"foo"];
This should be exactly the same. I can’t see how this could behave
like it does when the dot notation is simply syntactic sugar, as the
documentation states.
_________________________________________________________________
Marc Liyanage http://www.entropy.ch
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden