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

Syntax for int Array in Message (was: Objective-C Forum)


  • Subject: Syntax for int Array in Message (was: Objective-C Forum)
  • From: Jason Barker <email@hidden>
  • Date: Mon, 15 Jan 2007 16:21:19 -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? From my testing, I can use the

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


  • Prev by Date: Re: howto draw math forumulas
  • Next by Date: Re: howto draw math forumulas
  • Previous by thread: Re: NSString coding errors
  • Next by thread: setKeys + array operators = slowdown
  • Index(es):
    • Date
    • Thread