Reputation: 211
Thanks To all that helped problem solved. :)
For some reason this wont work for me please help
array = [[NSMutableArray alloc] init];
inputted = [input.text doubleValue];
[array addObject:[NSNumber numberWithDouble:inputted]];
NSLog(@"%i",array.count);
where array is a NSMutableArray, inputted is a double and input is a text field All that happens is that one saves but deletes the last one entered. how do i make it so that it saves everything entered?
Upvotes: 0
Views: 599
Reputation: 89509
You're always re-creating and re-initializing the "array
" mutable array each time you go through your function so it's no wonder you are getting a result of "1" (one object in the array).
If you initialize your array once and only once, and move it out and away from the rest of that code (i.e. into a different function or whatever), then you will add additional objects to your mutable array and you'll see the count increment each time you add an object to your mutable array.
Makes sense?
Upvotes: 1