Re: Syntax of int Array in Message (OT: Objective-C Forum)
Re: Syntax of int Array in Message (OT: Objective-C Forum)
- Subject: Re: Syntax of int Array in Message (OT: Objective-C Forum)
- From: glenn andreas <email@hidden>
- Date: Tue, 16 Jan 2007 11:58:23 -0600
On Jan 16, 2007, at 11:36 AM, Jason Barker wrote:
That worked! Thanks Glen. Why is this? Can NSObject be sent an
'initWithArray:' message? I don't see this in the API documentation.
No, but alloc returns an id, not an NSObject.
id's can be sent anything, so the compiler has to try to figure out
which many possibilities you mean (such as in this case, NSArray's
initWithArray: (NSArray *) and your initWithArray: (int [])). In
many cases, all that you get is a warning (because all that is
different is that it is a different kind of pointer) but in the case
of something like "length" you could get something that returns
either an int (possibly unsigned) or a floating value, and the
compiler has to pick one. If it picks wrong, you get garbage
(because ints and floats are returned differently).
Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium2 | build, mutate, evolve, animate | images, textures,
fractals, art
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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