• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: putting structs in NSArray
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: putting structs in NSArray


  • Subject: Re: putting structs in NSArray
  • From: "Philip D Riggs" <email@hidden>
  • Date: Tue, 26 Aug 2003 11:22:44 -0600

Maybe I'm missing something, too. I understood that NSArray and
NSMutableArray could only take NSObjects. Why not make this an NSObject str
and skip the NSValue etc. stuff? Aaron Hillegass' book has an example of
adding, accessing, and deleting objects in arrays.
================================
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)];

[a addObject: v];


----------------------------------------------------------------------------
----
Philip D. Riggs
GeoSpatial Analyst/ Laboratory Manager
Environmental Health Advanced Systems Laboratory
Colorado State University
Fort Collins, Colorado
970-491-6392
http://ehasl.cvmbs.colostate.edu/
_______________________________________________
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.

  • Follow-Ups:
    • Re: putting structs in NSArray
      • From: Justin Anderson <email@hidden>
  • Prev by Date: Re: cocoa-dev digest, Vol 2 #2848 - 10 msgs
  • Next by Date: Re: NSString -> char* ? Use -[NSString UTF8String].
  • Previous by thread: Re: putting structs in NSArray
  • Next by thread: Re: putting structs in NSArray
  • Index(es):
    • Date
    • Thread