Re: SIGBUS on declarations
Re: SIGBUS on declarations
- Subject: Re: SIGBUS on declarations
- From: "Sean McBride" <email@hidden>
- Date: Fri, 24 Aug 2007 13:47:24 -0400
- Organization: Rogue Research
On 8/24/07 10:40 AM, David Duncan said:
>> 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];
gcc can warn about this. With the OP's code it says:
"warning: missing sentinel in function call"
I forget which exact flag gives you this, but "-Wall" does. Pity
freshly created Xcode projects have so few warnings enabled.
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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