Tonight I installed Xcode 4 on my Macbook air and I use my main machine which is 6 core 3.33 ghz to do almost all of my coding. I did a build tonight and then tested the app on my Macbook air where it crashed after pressing an NSButton. I Could not find the code problem so I installed 4 on my Macbook air and dragged the project over to the laptop. The MacBook air was processing the code differently then my tower. I ran Xcode 4 at the same time with the same break points and then took a snap shot of both machines. Image to the left is MacPro, and the image to the right is the MacBook. For now forgive my bad naming of tempValue and TempValueTwo
I send a message to another Method from with in my first Method. I pass 1 argument which is the stringValue of a textField
In the next Method the hpTextField string value is numbers and a character like 'a'. Example '12a' or '45d'. I use an If statement to check if there is a character or just numbers the NSString *tempValue is nil, it skips it.
As a test number I used int 10; which is what the sender is. The MacPro version is correct and tempValue is nil. The MacBook somehow assigns the senders value to the tempValue which is now 10 and crashes my program. Here is the whole Method
I did solve the problem by initializing NSString tempValue to nil. But how 10 got assigned to tempValue I have no idea.
I send a message to another Method from with in my first Method. I pass 1 argument which is the stringValue of a textField
Code:
...
int scream;
yourHitPoints = [yourHpTextField intValue];
[COLOR="Red"][self convertButton:[hpTextField stringValue]];[/COLOR]
...
As a test number I used int 10; which is what the sender is. The MacPro version is correct and tempValue is nil. The MacBook somehow assigns the senders value to the tempValue which is now 10 and crashes my program. Here is the whole Method
Code:
- (IBAction)convertButton:(id)sender {
NSString *tempValue ;
//NSString *tempValueTwo;
scanLetter = [[NSScanner alloc] initWithString:[hpTextField stringValue]]; // Instantiate NSScanner for Letters and numbers
scanNumber = [[NSScanner alloc] initWithString:[hpTextField stringValue]];
NSCharacterSet *cSet = [NSCharacterSet characterSetWithCharactersInString:[hpTextField stringValue]]; //Convert string to an NSCharacterSet
[scanLetter setCharactersToBeSkipped:[NSCharacterSet decimalDigitCharacterSet]]; //Set up the scanner to remove all numbers.
[scanLetter scanCharactersFromSet:cSet intoString:&tempValue]; //Read in teh cSet and place them into the NSString
[COLOR="Red"] if (tempValue != nil) {
[critTextField setStringValue: tempValue];[/COLOR]
}
critValue = [self findCritValue:tempValue]; //converts letter to number or 0 if no match.
if (critValue == 0) {
// tempValueTwo = [NSString stringWithFormat:@"%d",0];
[critTextField setStringValue:@""];
}
[scanNumber scanInt: &hpStorage]; // Scans in the numbers.
[scanLetter release];
[scanNumber release];
}
I did solve the problem by initializing NSString tempValue to nil. But how 10 got assigned to tempValue I have no idea.