REAL newbie here to Objective C and Cocoa.
I have this ‘if statement’
if (cardCount = 2)
UIImage *image = [UIImage imageNamed: @"Card 2.png"];
This gives me “error: syntax error before ‘*’ token”
Why? The UIImage line works fine by itself.
I’d appreciate a pointer to what I’ve done wrong.
Thanks
Paul
First of all, the condition should read
cardCount == 2but that’s not the cause of that error. The problem is, variable declaration and initialization does not count as a statement in language grammar. It’s a declaration. You cannot have a declaration as the body ofif,while, etc. (by the way, a block is considered a statement, which might contain declarations, so that’s a different thing). After all, there’s no use to it as it’ll fall out of scope immediately so it’s disallowed.If you just need that variable in the if statement (I doubt this is what you want though):