I want to create 10 buttons using an array. How to create it? I am using
array = [[[NSArray alloc] initWithObjects:button1, button2] retain];
But It tells Missing Sentinel in Function Call. Where, I am wrong?
I want to create 10 buttons using an array. How to create it? I am using
array = [[[NSArray alloc] initWithObjects:button1, button2] retain];
But It tells Missing Sentinel in Function Call. Where, I am wrong?
NSArray *myButtons = [[NSArray alloc] initWithObjects:button1, button2, nil];
Now your array has retain count 1 after allocation, so you don't have to retain it.
When you don't need the array, just release it
[myButtons release];
The -initWithObjects:
method have to be nil
-terminated:
array = [[NSArray alloc] initWithObjects:button1, button2, nil];
// ^^^^^
Also, the +alloc
method already returns an object with retain count of +1. There's no need to -retain
it.
You are missing the terminating nil for the array.
array = [[[NSArray alloc] initWithObjects:button1, button2,nil] retain];
But thats possibly leaky as you get a double retain. Better might be.
array = [[NSArray arrayWithObjects:button1, button2,nil] retain];