Re: putting structs in NSArray
Re: putting structs in NSArray
- Subject: Re: putting structs in NSArray
- From: Dylan Adams <email@hidden>
- Date: Tue, 26 Aug 2003 09:58:09 -0500
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)];
The above line should be either
[NSValue valueWithBytes: &s objCType: @encode(struct str)];
or
[NSValue value: &s withObjCType: @encode(struct str)];
According to the documentation, they are equivalent.
[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?
What made you think that? The error message is pretty clear. There's no
class method on NSValue with the signature [value:objCType:]. There's
nothing in that error message about @encode.
dylan
_______________________________________________
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.