• 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 10:53:43 -0600


On Jan 16, 2007, at 10:31 AM, Jason Barker wrote:
- (id)initWithArray:(int[])array
[snip]
The problem I am having is when I pass an int array in the init message, I get the following warning: passing argument 1 of 'initWithArray:' from incompatible pointer type

However, when I pass the int array to the object with the 'resetWithArray:' message, it does not have this warning.

The reason is that the code: [[IntMatrix alloc] initWithArray: int_C]

is calling "initWithArray:" on the return value of alloc.

Alloc returns an id, so the compiler sees this as:

id someObject = [IntMatrix alloc];
[someObject initWithArray: int_C];

It decides that you must mean NSArray's "initWithArray:" which takes an NSArray *, not an int[], and this the warning. (You should probably also be getting a warning about ambiguous methods).

The best thing to do is to change your init method to "initWithIntArray:" and the problem will go away (since it will no longer clash with NSArray's, as well as being more like the standard name conventions).

Alternately, you could write [(IntMatrix *)[IntMatrix alloc] initWithArrray: int_C]


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


  • Follow-Ups:
    • Re: Syntax of int Array in Message (OT: Objective-C Forum)
      • From: Jason Barker <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>)

  • Prev by Date: Debuging
  • 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