• 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: 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.

  • Follow-Ups:
    • Re: putting structs in NSArray
      • From: Ben Dougall <email@hidden>
References: 
 >Re: putting structs in NSArray (From: Ben Dougall <email@hidden>)

  • Prev by Date: Re: Page Breaks in NSTextViews
  • Next by Date: testing right button
  • Previous by thread: Re: putting structs in NSArray
  • Next by thread: Re: putting structs in NSArray
  • Index(es):
    • Date
    • Thread