LoginSignup
1
0

More than 5 years have passed since last update.

c switch

Last updated at Posted at 2013-02-25

C、Objective-Cではswitchの中で宣言を行う場合はcaseを波括弧で囲う必要あるようなので注意

Objective-C
- (IBAction)buttonAction:(UIButton*)sender{
    switch (sender.tag) {
        case BTN_WRITE:{
            NSData *data = [self str2data:[_txtField.text]];
            break;
        }
        case BTN_READ:{
            NSData* data = [self file2data:@"test.txt"];
            [_txtField setText:[self data2str:data]];
        }
        default:
            break;
    }
}
1
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0