objective c - How to Add tag of NSCheckbox created dynamic to Array in Cocoa -


i created mutiple checkbox dynamic , set tag it, want check if checked, add tag nsarray. code create mutiple nscheckbox:

    for(int i=1; i<=number;i++) {      deletecheckbox= [[nsbutton alloc] initwithframe:nsmakerect (20,textfield_y,50,25)];     [deletecheckbox setbuttontype:nsswitchbutton];     [deletecheckbox setbezelstyle:0];     [deletecheckbox settitle:@""];     [deletecheckbox settag:200+i];     [deletecheckbox setstate:nsoffstate];     [deletecheckbox setaction:@selector(checkstate:)];     [guiview addsubview:deletecheckbox];     [deletecheckbox release]; } 

i used code add array:

    -(ibaction)checkstate:(nsbutton *)sender {     if ([sender state] == nsonstate) {         nslog(@"selected");         (int = 1; <=  number; ++) {             [deleteselectedarray addobject: [[guiview viewwithtag:200+i] intvalue]];          }         nslog(@"deleteselectedarray : %@",deleteselectedarray);      }     else {         nslog(@"not selected");     } } 

how can ? in advance

- (ibaction) checkstate: (nsbutton*) sender {     (int = 1; <= number; ++) {         if ([[guiview viewwithtag: 200 + i] state] == nsonstate) {             [deleteselectedarray addobject: [[guiview viewwithtag: 200 + i] intvalue]];         }     } } 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -