• 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
An Array of structs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

An Array of structs


  • Subject: An Array of structs
  • From: John Love <email@hidden>
  • Date: Fri, 27 Nov 2009 06:35:51 -0500

In my .h file, I have:

typedef struct YearAmt {
	NSString  *year;
	int       amount;
} YearAmt;

extern NSString *testy;
extern YearAmt gTest[];

In the corresponding .m file:

NSString *testy = @"testy";
YearAmt gTest[] = {{testy, 10}  /*, + others */};

I get "Initializer element is not constant. This pertains to the NSString* because if I directly substitute the following, no compile error happens:
YearAmt gTest[] = {{@"testy", 10}

What fundamental pertaining to C or C++ am I not getting?


John Love
Touch the Future! Teach!



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: An Array of structs
      • From: Jeremy Pereira <email@hidden>
    • Re: An Array of structs
      • From: Graham Cox <email@hidden>
  • Prev by Date: Invoking ImageKit effects panel
  • Next by Date: Conversion of CFSocketCreateWithNative -> NSSocketPort
  • Previous by thread: Invoking ImageKit effects panel
  • Next by thread: Re: An Array of structs
  • Index(es):
    • Date
    • Thread