2016年7月20日 星期三

#ifdef DEBUG



有時候,需要測試當在寫code時(debug),和實際產品時的不同:

這時候就可以用這小技巧:

設置:




之後要把設定打開,才能夠正確使用:




之後code內寫判斷:

#ifdef DEBUG
    NSLog(@"bebug");
    self.myLabel.text = @"DeBug";
#else
    NSLog(@"iiuytre");
//    UIAlertController *controller = [UIAlertController all];
//    [self presentViewController:controller animated:YES completion:nil];
    static NSString *STR = @"NOONO";
    self.myLabel.text = @"NONON";

之後就可以在debug的時候和實際產品時處理不同事情了

沒有留言:

張貼留言