What is the difference between these two ways of creating an NSArray.
Besides one being a class method and the other being an instance method. What is the difference ? When I use the class method my application will crash when I try to access the elements of my array.
+(id)arrayWithObjects
id)firstObj, ...;
-(id)initWithObjects
id)firstObj, ...;
myData = [NSArray alloc] initWithObjects
"foo",@"bar",nil];
do something with myData[index] all OK.
myData = [NSArray arrayWithObjects
"foo",@"bar",nil];
do something with myData[index] will crash without any exception or stacktrace.
What am I missing ?
Besides one being a class method and the other being an instance method. What is the difference ? When I use the class method my application will crash when I try to access the elements of my array.
+(id)arrayWithObjects
-(id)initWithObjects
myData = [NSArray alloc] initWithObjects
do something with myData[index] all OK.
myData = [NSArray arrayWithObjects
do something with myData[index] will crash without any exception or stacktrace.
What am I missing ?