objective c - Receiver type error Obj-C -
i'm trying make hangman game. realize methods aren't efficient. basically, each time letter entered i'm checking see if there empty spaces left can display "you won!" image. keep getting 2 errors:
receiver type 'char' not 'id' or interface pointer , consider casting 'id'
thread 1: exc_bad_access (code=1, address=0x63)
any appreciated.
bool dash = yes; for(int j = 0; j < self.correctword.length; j++){ char temp = [self.correctword characteratindex:j]; if([temp isequal:@"-"]) dash = yes; } if(dash == yes) self.hangmanimage.image = [uiimage imagenamed:@"wonimg"];
the thing objective-c it's 2-headed beast.
- there objects, send messages.
- there's plain c. no messages here, operators , function calls.
let's examine error:
receiver type 'char' not 'id' or interface pointer , consider casting 'id'
a "receiver" whatever receives message. making generalization no longer accurate, message square bracket stuff:
[receiver message]
or
[receiver messageargument1:arg1 argument2:arg2]
an id
type objective-c's notion of "any object".
so error trying receiver char
isn't object. it's plain c type. here's line problem:
if([temp isequal:@"-"])
for plain c type, test equality ==
operator:
if (temp == '-')
Comments
Post a Comment