FROM : Ricky Sharp
DATE : Mon Nov 22 19:13:27 2004
On Monday, November 22, 2004, at 12:10PM, Ricky Sharp <<email_removed>> wrote:
>On Monday, November 22, 2004, at 11:43AM, <<email_removed>> wrote:
>
>>How can i get a name as a NSString of a Class Object?
>Warning: I've never done any coding with the Obj-C structures directly, so no clue if this will even compile:
>
>- (NSString*)stringForClass:(Class)aClass
>{
> objc_class* classStructure = (objc_class*) aClass;
>
> return [[NSString alloc] initWithCString:[classStructure->name] autorelease];
>}
Don't do this. Use Scott Stevenson's suggestion of the NSClassFromString function. I keep forgetting about those functions when I search for APIs.
>Or, do you have an instance of the class you want a name for? If so, just call the className method (from NSObject)
This still applies if you have an instance of a class and need its name.
--
Rick Sharp
Instant Interactive(tm)
DATE : Mon Nov 22 19:13:27 2004
On Monday, November 22, 2004, at 12:10PM, Ricky Sharp <<email_removed>> wrote:
>On Monday, November 22, 2004, at 11:43AM, <<email_removed>> wrote:
>
>>How can i get a name as a NSString of a Class Object?
>Warning: I've never done any coding with the Obj-C structures directly, so no clue if this will even compile:
>
>- (NSString*)stringForClass:(Class)aClass
>{
> objc_class* classStructure = (objc_class*) aClass;
>
> return [[NSString alloc] initWithCString:[classStructure->name] autorelease];
>}
Don't do this. Use Scott Stevenson's suggestion of the NSClassFromString function. I keep forgetting about those functions when I search for APIs.
>Or, do you have an instance of the class you want a name for? If so, just call the className method (from NSObject)
This still applies if you have an instance of a class and need its name.
--
Rick Sharp
Instant Interactive(tm)
| Related mails | Author | Date |
|---|---|---|
| alex | Nov 22, 18:42 | |
| Scott Stevenson | Nov 22, 19:02 | |
| Tod Cunningham | Nov 22, 19:09 | |
| Ricky Sharp | Nov 22, 19:09 | |
| Ricky Sharp | Nov 22, 19:13 | |
| Daniel DeCovnick | Nov 22, 19:13 | |
| John C. Randolph | Nov 22, 20:13 | |
| Sherm Pendley | Nov 22, 20:30 | |
| Shawn Erickson | Nov 22, 20:43 |






Cocoa mail archive

