I am having trouble trying to run this test due to an error on the first line of this code that states:
Incompatible pointer to integer conversion initializing 'int' with an expression of type 'NSString *'
- (IBAction)Button:(id)sender { int x = TramNumber.text; if (x < 9) { Tramresult.text = [NSString stringWithFormat:@"lol"]; } else { NSLog (@"x is less than 9!"); } } @end
Please help. I am on iOS and running xCode 5.1.1 if that helps.
6 int answer = [@"42" intValue]; 7 NSString *answerString = 8 [NSString stringWithFormat: @"%d", answer]; 9 NSNumber *boxedAnswer = 10 [NSNumber numberWithInt: answer]; 11 NSCAssert([answerString isEqualToString: 12 [boxedAnswer stringValue]], 13 @"Both strings should be the same");
A static, plain-text Unicode string object that bridges to String ; use NSString when you need reference semantics or other Foundation-specific behavior.
You are representing NSString
value wrong.
Use this code sample to solve your problem:
int x = [TramNumber.text intValue];
To represent int value from your textfield.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With