0

I'm quite new to Objective-C and having trouble understanding the source code written by other developers. In the current app I'm currently working on, sometimes, I saw the comma in the method call like this one:

[UIAlertView * alert = [UIAlertView alloc] initWithTitle:<#(NSString *)#> message:<#(NSString *)#> delegate:<#(id)#> cancelButtonTitle:<#(NSString *)#> otherButtonTitles:<#(NSString *), ...#>, nil];

But I'm not quite understand what the last , nil means even though someone told me that's the pointer that references to the location in computer memory. But it sounds really vague to me.

Can you help me understand the idea using here?

  • 3
    It means that it's a `nil` terminated list. So if you had three buttons, it might be `otherButtonTitles: @"foo", @"bar", @"baz", nil`. It has no way of knowing how many are in the list, so you put `nil` at the end of the list and that's how it knows there are no more items. – Rob Jun 25 '15 at 02:57
  • 1
    [Why do ObjC array parameters not use colon notation?](http://stackoverflow.com/q/30851034) might also be a good read. – jscs Jun 25 '15 at 03:17

0 Answers0