Re: putting structs in NSArray
Re: putting structs in NSArray
- Subject: Re: putting structs in NSArray
- From: "Alastair J.Houghton" <email@hidden>
- Date: Tue, 26 Aug 2003 12:42:08 +0100
On Tuesday, August 26, 2003, at 12:09 pm, Ben Dougall wrote:
this works fine for an NSRange:
NSRange r = NSMakeRange(50, 5);
NSValue *v = [NSValue valueWithBytes:&r objCType:@encode(NSRange)];
[array addObject: v]; // puts encoded struct into NSMutableArray
+valueWithBytes:objCType: appears to be deprecated in favour of
+value:objCType:, although some of the documentation seems to need
updating to say so.
but what about with another struct like say:
struct str s = {123456, '*', YES};
how can i now add s into an NSMutableArray?
Have you tried
NSValue *v = [NSValue value:&s objCType:@encode(struct str)];
See
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/
4objc_runtime_overview/chapter_4_section_6.html
for more information about @encode().
Kind regards,
Alastair.
_______________________________________________
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.