objective c - Beginning NSMutableArray - Debug ignored -


i learning objective-c. simple fix has worked nsmutablearrays before.

note: have watched 3 videos on tube , read 5 articles before asking question. there plenty of resources available setvalue:forkey, don't believe applies scenario.

i trying use simple array support selections made in tic tac toe game. concept simple: - array instantiated 9 array nodes - when selection made current letter placed in corresponding array node - method check end of game reference array nodes.

problems: - tried set nsnull values instead of @"" each default object. error of "unexpected interface name 'nsnull'. - nslog logic debug array nodes never executes. assumption array not being populated.

 @synthesize lblstatus, currletter; @synthesize selections; @synthesize btn0, btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8;  - (void)viewdidload {     [super viewdidload];      [selections initwithobjects:      @"", @"", @"", @"", @"", @"", @"", @"", @"", nil];      currletter = @"x";     [self updatetitle];     // additional setup after loading view, typically nib. }  - (ibaction)taketurn:(id)sender {     uibutton *btn = (uibutton *)sender;     if (btn.currenttitle == nil) {         [selections replaceobjectatindex:btn.tag withobject:currletter];         [sender settitle:currletter forstate:uicontrolstatenormal];         [self changeturns];     } }  - (void)changeturns {      if ([currletter isequaltostring:@"x"]) {         currletter = @"o";     } else {         currletter = @"x";     }      (nsstring *node in selections) {         nslog([nsstring stringwithformat:@"node: %@", node]);     }      [self updatetitle]; }  - (void)updatetitle {     [lblstatus settext:[nsstring stringwithformat:@"%@'s turn", currletter]]; } 

if see else considered "bad code" i'll gladly take feedback also.

any appreciated.

instead of [selections initwithobjects: @"", @"", @"", @"", @"", @"", @"", @"", @"", nil];

write selections = [[nsmutablearray alloc] initwithobjects: @"", @"", @"", @"", @"", @"", @"", @"", @"", nil];


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -