Monday, 15 July 2013

cocoa - NSArray initialization with numbers -


I was thinking about how to create an NSArray with 1-100 numbers I can be used in a UIPickerView .

I know other programming classes which I can do:

  int array [100]; For (int i = 1, i & lt; = 100, i ++) array [i] = i;  

But I'm not sure how to do something similar to NSArray instead of typing all the values ​​manually, I searched it online and I used to call it Colok and it was uncertain that this was the best way, or if I can wrap anything in any way in NSNumber and every NSNumber < / Code> Go to my array and if I had to do this procedure, would I ever have to loop the Can I create a NSMutableArray and addObject running? When the user goes to the screen, I want to load these values.

Either:

  NSArray * array = [NSArray array] ; For (int i = 1; i  

Or:

  NSMutableArray * array = [[nmutabalarol] initWithCapacity: 100]; For (Int i = 1; I  

... you should do whatever you like. If there is something that you are doing often, then you might consider creating a category to build a category that creates a category.


No comments:

Post a Comment