简体   繁体   中英

Objective-c: expected identifier

I am a total newbie with objective C and IOS programming trying to follow along with a tutorial from a book by Nick Kuh.

The tutorial says to put the following code in the ViewController implementation file and it is returning the error: "Expected Identifier".

Have I typed something wrong or could it be a typo in the book? I don't even know what an expected identifier means in this context so would appreciate any help as I am totally stuck.

The part of the code sample highlighted in red in Xcode is

object:[self.gameModel]; I bolded it below and SO put ** on either side.

-(id) initWithCoder:(NSCoder *)aDecoder
{
    self=[super initWithCoder:aDecoder];
    if (self) {
        self.gameModel = [[BJDGameModel alloc] init];
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(handleNotificationGameDidEnd:) name:BJNotificationGameDidEnd
                                                   **object:[self.gameModel];**
         }
         return self;
}
[[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(handleNotificationGameDidEnd:) name:BJNotificationGameDidEnd
                                                   object:[self.gameModel];

remove the square bracket before self.gameModel

[[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(handleNotificationGameDidEnd:) name:BJNotificationGameDidEnd
                                                   object:self.gameModel];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM