Chris Barry Chris Barry - 1 month ago 5
Objective-C Question

How to create an Array of Strings in Objective c for iphone

I'm trying to create an array of strings that can be randomized and limited to a certain x number of strings.

If the array could be randomized I could pick the first x strings and that would work fine.

I'm trying to use code like this currently

NSString *statements[9];
statements[0] = @"hello";

This seems to work but the array seems to be full of rubbish data.

Can someone help me in the right direction. (is the memory allocation being done in the wrong way?



Do you want an array with nine strings in it?

[NSArray arrayWithObjects: @"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", nil]