Re: putting structs in NSArray
Re: putting structs in NSArray
- Subject: Re: putting structs in NSArray
- From: Glen Simmons <email@hidden>
- Date: Tue, 26 Aug 2003 09:48:41 -0500
On Tuesday, August 26, 2003, at 08:46 AM, Ben Dougall wrote:
i just can't suss this one. trying to put a struct into an array:
struct str {
int x;
char y;
BOOL z;
};
struct str s = {123456, '*', YES};
NSMutableArray *a = [[NSMutableArray alloc] initWithCapacity:2];
NSValue *v = [NSValue value:&s objCType:@encode(struct str)];
This should be NSValue *v = [NSValue value:&s
withObjCType:@encode(struct str)];
Notice the "with". Whenever you get a "cannot find ... method" warning,
odds are you've misspelled the method name.
[a addObject: v];
for the NSValue line i get:
main.m:34: warning: cannot find class (factory) method
main.m:34: warning: return type for `value:objCType:' defaults to id
seems as if @encode isn't getting the information it needs - it's not
linking up with the str struct declaration or something? what am i
doing wrong?
if anyone's got any ideas it'd be much appreciated. thanks, ben.
HTH,
Glen
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.