for(NSInteger i = 0; i<[_tempPostalCodeList count]; i++){
***if(individualInfo.postalCode == [[_tempPostalCodeList objectAtIndex:i] postalCode])***{
myAnnotation.title = [NSString stringWithFormat:@"%i Records!", [[_postalCount objectAtIndex:i] intValue]];
}
}
I Do not know what is wrong with this piece of code. That line has a error.
This works for Java but not for objective c. =( Someone plz help
Despite the lack of a lot of information in the question, my psychic powers tell me that the problem is that the message
-objectAtIndex:of theNSArrayclass returns a generic object of typeid. So, the expression[[_tempPostalCodeList objectAtIndex:i] postalCode]is sending thepostalCodemessage to an object of typeid. Since the compiler doesn’t know the underlying type of the actual object, it can’t deduce the return type of thepostalCodemessage, so it assumes that it also returnsid.idis a pointer type, and sincepostalCodeis an integral type, the compiler thinks you’re trying to compare a pointer with an integer when it evaluates the==operator, hence the warning. The way to fix this is to either insert a cast, or introduce a temporary variable:The reason that you can use a temporary variable without a cast is because the
idtype (returned by-objectAtIndex:) can be implicitly cast to any Objective-C class type by simple assignment (similar to how in C (but not C++), thevoid*type can be implicitly cast to any pointer type).