I'm making this function that takes a string input, converts it to an int, and finds the binary equivalent. It was working an hour ago, but after i tried tinkering with a different keypad, and then going back, it no longer works:
- (void)convertToBinary:(NSString *)tf
{
NSString *result = @"";
NSLog(@"-- %@", tf); //successfully prints
[tf retain];
if ([tf isKindOfClass:[NSString class]]){
NSLog(@"tf is NSString"); //THIS PRINTS SO TF IS CONFIRMED TO BE NSSTRING
}
int dec = [tf intValue]; //BREAKS HERE...!
if (!dec){
[binaryOutput setText:@"Sorry, invalid input!"];
} else {
...
}
}
I know that to convert an NSString to an int, i just need to do int dec = [someString intValue]
yet that isn't working. The error i'm getting is EXEC_BAD_ACCESS
Any help please?
EDIT
I just made a small command-line project:
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// insert code here...
NSString *t = @"123";
int d = [t intValue];
NSLog(@"Hello, %@", d);
[pool drain];
return 0;
}
and the EXEC_BAD_ACCESS still persists for such a simple program! What's the problem here?