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.

  1. there objects, send messages.
  2. 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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -