iphone - Unwind ViewController -
i trying unwind view controller when user clicks cell. error unrecognized selector sent instance ... 2 nslogs inserted not show when click cell, crashes error. here code prepareforsegue method
- (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { nsstring *pointspath = [[nsstring alloc] initwithformat:@"totalpoints"]; nsstring *primarypath = [[nsstring alloc] initwithformat:@"type"]; int primarytype = [[nsuserdefaults standarduserdefaults]integerforkey:primarypath]; int totalpoints = [[nsuserdefaults standarduserdefaults]integerforkey:pointspath]; [[nsuserdefaults standarduserdefaults] setinteger:1 forkey:@"classtype"]; if([sender row] == 0) { nslog(@"chose 0"); if(primarytype > 0) { [[nsuserdefaults standarduserdefaults]setinteger:0 forkey:primarypath]; int newpoints = totalpoints - 1; [[nsuserdefaults standarduserdefaults]setinteger:newpoints forkey:pointspath]; [[nsuserdefaults standarduserdefaults] synchronize]; } else if (primarytype == 0) { [[nsuserdefaults standarduserdefaults]setinteger:0 forkey:primarypath]; [[nsuserdefaults standarduserdefaults]synchronize]; } } else if([sender row] > 0 && [sender row] < [self.guns count]) { int rownumba = [sender row]; nslog(@"you chose row #%i", rownumba); int numbertosave = [sender row]; if(totalpoints < 10) { if(primarytype != 0) { [[nsuserdefaults standarduserdefaults]setinteger: numbertosave forkey:primarypath]; [[nsuserdefaults standarduserdefaults]synchronize]; } else if (primarytype == 0) { [[nsuserdefaults standarduserdefaults]setinteger:numbertosave forkey:primarypath]; int newpoints = totalpoints + 1; [[nsuserdefaults standarduserdefaults]setinteger:newpoints forkey:pointspath]; [[nsuserdefaults standarduserdefaults] synchronize]; } } else if (totalpoints >= 10 && primarytype != 0) { uialertview *alert = [[uialertview alloc] initwithtitle:@"too many points!" message:@"you have maximum amount of points" delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil]; [alert show]; } }
there couple of things wrong setup. first, should never go backwards using segue, unless you're using unwind segue. i'm not sure if that's what's causing problem, that's bad. since modal transition view1 view2, should go dismissviewcontrolleranimated:completion:, not segue (unless, said want use unwind). second, it's not @ clear you're trying tab bar controller. think if want view2 first tab of tab bar controller, segue view1 should go tab bar controller not view2. don't presenting tab bar controllers modally, think should window's root view controller. purpose of view1? why have s initial view controller?
Comments
Post a Comment