• 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: SIGBUS on declarations
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SIGBUS on declarations


  • Subject: Re: SIGBUS on declarations
  • From: David Duncan <email@hidden>
  • Date: Fri, 24 Aug 2007 10:40:45 -0700

On Aug 24, 2007, at 10:32 AM, Jason Whittle wrote:

NSArray* x = [[NSArray alloc] initWithObjects: [NSNumber numberWithInt: 1]];

Note the prototype for initWithObjects: "- (id)initWithObjects:(id)firstObj, ..."

So that means that it takes a variable length parameter list, but there is no way for it to know what the end of the list is without you telling it. According to the docs, this list is a "A comma- separated list of objects ending with nil". So you need to terminate the list with nil. Your code should be instead:

NSArray* x = [[NSArray alloc] initWithObjects: [NSNumber numberWithInt: 1], nil];
--
David Duncan
Apple DTS Quartz and Printing
email@hidden



_______________________________________________

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: SIGBUS on declarations
      • From: "Sean McBride" <email@hidden>
References: 
 >SIGBUS on declarations (From: Jason Whittle <email@hidden>)

  • Prev by Date: SIGBUS on declarations
  • Next by Date: NSSplitView / NSWindow resize problem
  • Previous by thread: SIGBUS on declarations
  • Next by thread: Re: SIGBUS on declarations
  • Index(es):
    • Date
    • Thread