If I write the following function, I get a warning and an error on the third line.
int myYear (NSString *timevar)
{
if ([timevar isEqualToString:@"yr"]) {
return ...
}
}
Xcode says
- Semantic Issue: Implicit declaration of function ‘If’…
- Parse Issue: Expected ‘;’ after expression
What am I doing wrong?
This is because
ifis a keyword, and keywords in Objective C are case-sensitive*. Same goes for other keywords, such asint.* This is not a universal rule: for example, VB.NET will accept both
ifandIf.