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

Syntax of int Array in Message (OT: Objective-C Forum)


  • Subject: Syntax of int Array in Message (OT: Objective-C Forum)
  • From: Jason Barker <email@hidden>
  • Date: Tue, 16 Jan 2007 09:31:11 -0700

On Jan 15, 2007, at 1:14 PM, Scott Stevenson wrote:


On Jan 15, 2007, at 9:05 AM, Jason Barker wrote:

I am looking for a "lively" Objective-C forum. Can anyone suggest one that is reliable and highly-trafficked?

You're standing in it.

- Scott


Alright then.

I have a class "IntMatrix" in which I want to hold a two-dimensional array of ints. It has the following init message which also sends a message 'resetWithArray:' to itself:

/**
 * Initialize this object with an array of ints.
 */
- (id)initWithArray:(int[])array
{
  self = [super init];
  if(self != nil)
  {
    [self resetWithArray:array];
  }

  return self;
}


/** * Reset the int matrix of this object. */ - (void)resetWithArray:(int[])array { int n, i = 0, j = 0, last = CELLS_PER_ROW * CELLS_PER_COLUMN;

  for(n = 0; n < last; n++)
  {
    matrix[i][j] = array[n];
    if(++j == CELLS_PER_COLUMN)
    {
      j = 0;
      i++;
    }
  }
}

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. Can someone explain what the difference is and how I could correct this so that there is no warning for using the 'initWithArray:' message? It seems to work both ways but I get the warning when I pass the array in the init message and it bothers me.

By the way, I am creating the array as follows:
int _C[] = {0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6};


Thank you, Jason


_______________________________________________

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: Jon Hendry <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: "Nick Kreeger" <email@hidden>
References: 
 >OT: Objective-C Forum (From: Jason Barker <email@hidden>)
 >Re: OT: Objective-C Forum (From: Scott Stevenson <email@hidden>)

  • Prev by Date: Preventing NSSlider bar from drawing
  • Next by Date: Re: Syntax of int Array in Message (OT: Objective-C Forum)
  • Previous by thread: Re: OT: Objective-C Forum
  • Next by thread: Re: Syntax of int Array in Message (OT: Objective-C Forum)
  • Index(es):
    • Date
    • Thread