General noob questions:
(1) How can I create an NSMutable array in a NSMutable action to which I can add more entries during subsequent clicks of the same button? I always start with a new array each time I click (the array prints with only 1 entry, which is the most recent button tag in the NSLog statement).
I have about 100 buttons (one for each character in my line called a "list") generated by a for-loop earlier in my code, and a tag has been assigned to each of them. They are in scrollview in the view of my ViewController .
I want to track how many (and which) buttons were pressed , with the ability to delete these entries, if they are pressed a second time ,
This is what I have so far:
-(void) buttonClicked:(UIButton *)sender NSMutableArray * theseButtonsHaveBeenClicked = [[NSMutableArray alloc] initWithCapacity: list.length]; NSNumber *sendNum = [NSNumber numberWithInt:sender.tag]; [theseButtonsHaveBeenClicked addObject:sendNum at index:sender.tag]; NSLog(@"%@",theseButtonsHaveBeenClicked); }
(2) I read that I can use the plist dictionary, but I really don’t understand how to do this in the code, because I cannot print elements in the dictionary manually (since I don’t know which buttons the user clicks). Would it be easier if I somehow downloaded and replaced the dictionary in the plist file? And how would I do that?
(3) I also don’t know how to manage memory, since I need to constantly update the array. autorelease ?
Thanks for any help you can provide!
source share