Re: If Statements In Objective C For IOS Development
Re: If Statements In Objective C For IOS Development
- Subject: Re: If Statements In Objective C For IOS Development
- From: Kevin Muldoon <email@hidden>
- Date: Sat, 15 Jun 2013 11:36:26 -0400
I may not be reading this right, but it looks like you're doing math calc on the objects, rather than the values within the objects. See if this works for you…
- (IBAction)nextButtonAction:(id)sender {
int textFieldOneTextAsInteger = [self.textFieldOne.text integerValue];
int textFieldTwoTextAsInteger = [self.textFieldTwo.text integerValue];
int textFieldThreeTextAsInteger = [self.textFieldThree.text integerValue];
if (textFieldOneTextAsInteger * textFieldTwoTextAsInteger > textFieldThreeTextAsInteger) {
self.label.text = @"One value";
} else if (textFieldOneTextAsInteger * textFieldTwoTextAsInteger < textFieldThreeTextAsInteger){
self.label.text = @"Another value";
} else {
self.label.text = @"They are the same value";
}
}
On Jun 15, 2013, at 10:53 AM, Harmony Neil <email@hidden> wrote:
> Hellow,
> I've been rewriting my IOS app (mainly because I had to) and got my 3 text fields: t1, t2, and t3 being what I'm calling them. I've also got a label on there. What I want to do is have it so that if t2 multiplied by t3 is greater than t1 the text on the label says one thing, if t2 multiplied by t3 is less than t1 the text on the label to say something else and if it is the same, say something else. However xcode doesn't like my if statement. it's complaining about the line:
> if (t2*t3>t1)
> {
> self.label.text=@"1 bit of text for example";
> }
>
>
> I've tried running the app, and xcode is complaining about the t1, t2 and t3 things in the if statement … Something about identifiers. The way I got round it before was to have 1 label showing the result of t2 multiplied by t3, then another label saying the text that I wanted, but I really want to make it tidier this time around.
> Can anyone help me fix this? And I didn't say can anyone suggest any books or whatever either. I'm tired of making my screen reader read long pages.
> Thanks for any code suggestions etc though,
> Harmony._______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden