• 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: Syntax of int Array in Message (OT: Objective-C Forum)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >OT: Objective-C Forum (From: Jason Barker <email@hidden>)
 >Re: OT: Objective-C Forum (From: Scott Stevenson <email@hidden>)
 >Syntax of int Array in Message (OT: Objective-C Forum) (From: Jason Barker <email@hidden>)
 >Re: Syntax of int Array in Message (OT: Objective-C Forum) (From: glenn andreas <email@hidden>)
 >Re: Syntax of int Array in Message (OT: Objective-C Forum) (From: Jason Barker <email@hidden>)

  • Prev by Date: Best way to use NSView in more than one NSToolbar simultaneously?
  • Next by Date: RE: Debuging
  • Previous by thread: Re: Syntax of int Array in Message (OT: Objective-C Forum)
  • Next by thread: Re: Syntax of int Array in Message (OT: Objective-C Forum)
  • Index(es):
    • Date
    • Thread