I开发者_开发百科 want to have user select between two different buttons on a view, If the the user selects the imageOne, a label is created called "imageOne", then I'll save the label into an array using the following technique:
- (IBAction)saveData {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *choice = [NSString stringWithFormat:@"%@/userschoice", documentsDirectory];
NSMutableArray *array = [[NSMutableArray alloc] init];
[array addObject:imageOne.text];
[array writeToFile:choice atomically:NO];
}
I'm trying to avoid using the Picker and a Tableview as I only have two choices and it will be easier for user to choose with a button. any guidance would be appreciated.
Thanks.
Michael
- Create the button, either in Interface Builder or in code
- Hook up the button's delegate to point to the controller
- Implement a method to do something in the controller (see link from number 2)
- Save data
精彩评论