[Solved] how to check multiple buttons click and save the value on plist? [closed]


*If I understood what you want then here is some logic. You can add/remove to make upto your requirement.

*Directly typed here, errors/typos probable. Please conside.

In your interface file:

@property BOOL yourChoice;//0-easy, 1-hard
@property BOOL plus;
@property BOOL minus;
@property BOOL divide;
@property BOOL multipy;
@property (strong) NSInteger score;
@property (strong) NSMutableArray *scores;

In your implementation file:

-(IBAction)easy:(id)sender{
    yourChoice=0;
}

-(IBAction)hard:(id)sender{
    yourChoice=1;
}

In choices action method, instead of tag i am checking it with title to make it readable.

//NSString *title=[(UIButton *)sender currentTitle]; //to get name in ios
-(IBAction)choices:(id)sender{// i have used osx style
     NSString *title=[(UIButton *)sender currentTitle];
     if([title isEqualToString:@"Plus"]) plus=1;
     else if([title isEqualToString:@"Minus"]) minus=1;
     else if([title isEqualToString:@"Divide"]) divide=1;
     else if([title isEqualToString:@"Multiply"]) multiply=1;
     self.score=plus+minus+divide+miltiply;
}

-(IBAction)showScore:(id)sender{
   NSString *choice=yourChoice?@"Hard":@"Easy";
   NSLog(@"Score for %@ is %d.", choice, self.score);

   self.scores[self.scores.count]=@(self.score);
   //reset every value
   youChoice=plus=minus=divide=multiply=score=0;

}

0

solved how to check multiple buttons click and save the value on plist? [closed]