I have an app which works on 32-bit platforms but throws an error when running on 64-bit devices and simulators. The code in question is:
if ([lastStatus isEqualToString:@"0"]){ //EXC_BAD_ACCESS
bRetVal = YES;
}
From my class h file:
@interface DPXmlHandler : NSObject <NSXMLParserDelegate> {
NSString *lastStatus;
NSString *msg;
NSMutableArray * locs;
NSMutableArray *alerts;
NSMutableArray *mrmMsgs;
}
@property (nonatomic, copy) NSString *lastStatus;
I synthesize lastStatus at the top of my .m file. I am populating the string with a value from an XML file. - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
if ([elementName isEqual:@"status"]) {
//Get attribute value
@try{
lastStatus = [attributeDict valueForKey:@"code"];
msg = [attributeDict valueForKey:@"message"];
}@catch (NSException *e){
NSLog(@"Exception: %@", e);
msg = e.name;
}
The value is an integer, but I'm failing to understand why I can't store a string of "0" and compare it to @"0". I would appreciate any insight on how to change this. The values for lastStatus are from roughly -100 to 100. I can make lastStatus an int or long and use the == operator, but I can't seem to find any guidance on WHY this is a problem.
I checked Apple's guide on converting apps to 64 bit, but there's no mention of NSString.
[attributeDict valueForKey:@"code"]
is actually a string, could be something funky happening there – Fonix