1
NSMutableArray *firstColumn = [[NSMutableArray alloc]init];
[firstColumn addObject:tile1];
[firstColumn addObject:tile2];
[firstColumn addObject:tile3];

When you use addObject on to a NSMUtableArray, we do not add "nil" but when initWithObjects is used, there is a "nil" parameter in the statement.

What does nil signify? Does it mention that it's reaching the end of the Array ?

 NSMutableArray *thirdCoulmn =[[NSMutableArray alloc] initWithObjects:tile7,tile8,tile9,nil];
Jash Jacob
  • 580
  • 1
  • 13
  • 29
  • 2
    Yeah, it's a sentinel value. varargs functions either need a sentinal value or some other way to keep track (eg printf uses the format string) – sapi Sep 07 '14 at 06:58

1 Answers1

2

As mentioned in the comment, this doesn't have to do with NSMutableArray, but the vargs features (variable arguments). It uses a sentinel value, nil, to determine the end of the argument list.

Search for vargs to learn more about this feature.

Community
  • 1
  • 1
Mazyod
  • 22,319
  • 10
  • 92
  • 157