I\'m coming from an Objective-C background and am trying to expand my knowledge in C. One thing has me confused, however, and that\'s the difference between pointers in C and O
What are you trying to do?
Not sure if it will work as you intended.
You seem to be taking concepts from C and apply it to Cocoa classes, I thought you were learning C. Have you seen anywhere in Objective-C code taking address of an object?
Cocoa classes are implemented using Class clusters
which mean that they share the same interface but you will get specific extended class which you manipulate.
In your case you are taking address of possibly class that extends NSString
and assign it to pointer to NSString
.
Example:
NSString * str = @"Caramel coffee";
NSString * str2 = [NSString stringWithString:@"all"];
NSLog(@"%@", [[str class] className]);
NSLog(@"%@", [[str class] className]);
Output (GNUStep linux):
2009-12-08 10:49:29.149 x[25446] GSCInlineString
2009-12-08 10:49:29.149 x[25446] NSConstantString
... apart from the obvious pointer definition problems pointed out by others.