Tutorial details

If Statements | App Code for Sale | Preview

If Statements | iOS Tutorial

How to use if statements in your apps

Overview PAGE TOP

Reference: http://www.geekylemon.com/xcode-if-statements

In this tutorial i will be showing you how to use if statements in your apps

Features:

  • 4 Buttons
  • 2 Labels

If statements are a very useful feature for app development you can set stuff to do certain things depending on the state of another

ViewController.h PAGE TOP

@interface ViewController : UIViewController {
IBOutlet UILabel *Label1;
IBOutlet UILabel *Label2;
}
- (IBAction)Button1;
- (IBAction)Button2;
- (IBAction)Button3;
- (IBAction)Button4;
- (IBAction)PressMe;
@end

ViewController.m PAGE TOP

@implementation ViewController
- (IBAction)Button1 {
Label1.text = @"1";
}

- (IBAction)Button2 {
Label1.text = @"2";
}

- (IBAction)Button3 {
Label1.text = @"3";
}

- (IBAction)Button4 {
Label1.text = @"4";
}

- (IBAction)PressMe {
if ([Label1.text isEqualToString:@"1"]) {
Label2.text = @"One";
}
if ([Label1.text isEqualToString:@"2"]) {
Label2.text = @"Two";
}
if ([Label1.text isEqualToString:@"3"]) {
Label2.text = @"Three";
}
if ([Label1.text isEqualToString:@"4"]) {
Label2.text = @"Four";
}
}

@end

Reference PAGE TOP

http://www.geekylemon.com/xcode-if-statements

0 Comments Leave a comment

Please login in order to leave a comment.

Newest first
!

Sign-in to your Chupamobile Account.

The Easiest way to Launch your next App or Game.

Join Chupamobile and get instant access to thousands of ready made App and Game Templates.

Creating an account means you’re okay with Chupamobile’s Terms of Service and Privacy Policy.