ios - UIAlertView save textfield.tex -
i want replay alertview textfield until canceled. text in textfield should save in nsmutablearray
. tried something, doesn't work. mynsmutablearray = ...
expected identifier. doing wrong?
@synthesize mynsmutablearray; - (void)viewdidload { [super viewdidload]; [self alert]; } - (void)alertview:(uialertview *)alertview clickedbuttonatindex: (nsinteger)buttonindex { if (buttonindex == 0) { mynsmutablearray = [[nsmutablearray alloc] addobject:[[alertview textfieldatindex:0].text]]; [self alert]; } else{ nslog(@"done"); } } -(void)alert{ uialertview *alert = [[uialertview alloc] initwithtitle:@"titel" message:@"message" delegate:self cancelbuttontitle:@"next" otherbuttontitles:@"done", nil]; alert.alertviewstyle = uialertviewstyleplaintextinput; [[alert textfieldatindex:0] setplaceholder:@"first"]; [alert show]; }
you have number of issues , demi-issues:
remove @synthesize
, should pretty never using now. need create array in advance rather repeatedly creating , not initialising (thus destroying previous object). , have many brackets around text field usage when you're using dot notation.
remember, if have issues line of code compiling, break out parts can see bit has issue , code easier follow through.
- (void)viewdidload { [super viewdidload]; self.mynsmutablearray = [nsmutablearray array]; [self alert]; } - (void)alertview:(uialertview *)alertview clickedbuttonatindex:(nsinteger)buttonindex { if (buttonindex == 0) { [self.mynsmutablearray addobject:[alertview textfieldatindex:0].text]; [self alert]; } else{ nslog(@"done"); } } -(void)alert { uialertview *alert = [[uialertview alloc] initwithtitle:@"titel" message:@"message" delegate:self cancelbuttontitle:@"next" otherbuttontitles:@"done", nil]; alert.alertviewstyle = uialertviewstyleplaintextinput; [[alert textfieldatindex:0] setplaceholder:@"first"]; [alert show]; }
Comments
Post a Comment