Re: Couple of questions about the "SEL" datatype
Re: Couple of questions about the "SEL" datatype
- Subject: Re: Couple of questions about the "SEL" datatype
- From: Jonathon Mah <email@hidden>
- Date: Mon, 24 Jan 2005 14:24:51 +1030
On 24 Jan 2005, at 07:21, Ken Tozier wrote:
Is the SEL datatype fixed in size?
A "SEL" is simply a C string (char *) that is unique in the runtime.
Thus:
NSString *method1 = @"copyWithZone:";
NSMutableString *method2 = [[NSMutableString alloc]
initWithString:@"copyWIthZone:"];
// Now (method1 != method2), because they are different points in
memory.
SEL sel1 = NSSelectorFromString(method1);
SEL sel2 = NSSelectorFromString(method2);
// Now (sel1 == sel2), i.e. they both point to the exact same
string in memory
NSLog(@"Selector is this: %s", (char *)sel1);
You won't be able to store a SEL (i.e. the address it points to) on
disk and have it work again later (after relaunching your app), but you
can (as mentioned) store the NSString (or even the C string) and get
the correct pointer through NSSelectorFromString.
Jonathon Mah
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden