Reputation: 1873
I am trying to compare the annotation title with title values to put different annotation image for different annotations. I tried to compare like in PHP:
if(title == "parking" || title = "car")
{
}
in Objective C I tried to do it like:
if([[annotation title] isEqualToString:@"Parking" || [annotation title] isEqualToString:@"Peace Hall" ] )
{
}
but it did not work. How can I accomplish this ?
Upvotes: 0
Views: 235
Reputation: 6131
You need to send each isEqualToString:
message separately, i.e.
if ([[annotation title] isEqualToString:@"Parking"] || [[annotation title] isEqualToString:@"Peace Hall"])
{
}
Upvotes: 0
Reputation: 212949
Change:
if ([[annotation title] isEqualToString:@"Parking" || [annotation title] isEqualToString:@"Peace Hall"])
to:
if ([[annotation title] isEqualToString:@"Parking"] || [[annotation title] isEqualToString:@"Peace Hall"])
Upvotes: 1
Reputation: 956
Looks like you just messed up the syntax. Try this:
if([[annotation title] isEqualToString:@"Parking"] || [[annotation title] isEqualToString:@"Peace Hall"] ) {
/* Code */
}
Upvotes: 2