我是非常新的Xcode,但我希望添加一些額外的功能,我的基本應用程序。此功能應在首次啓動時記錄一個字符串。出於調試目的,我也要求程序輸出一個字符串,即使它不是第一次啓動。我似乎無法在任何地方找到這些消息(我假設Xcode會像大多數IDE那樣捕捉到它們)。我是否在正確的文件中做這件事?該應用程序使用標籤欄控制器。Objective-C第一次啓動代碼被忽略
感謝
//
// ViewController.m
//
// Created by Joel Kidd on 29/05/2013.
//
//
#import "ViewController.h"
@interface ViewController()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"FirstLaunch"]) {
NSLog(@"This is not the first launch.");
} else {
// Place first launch code here
NSLog(@"This is the first launch!");
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"FirstLaunch"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
所有'NSLog'消息都應該出現在調試區域面板(視圖>調試區域>激活控制檯)中,並且應用程序委託的'application:didFinishLaunchingWithOptions:'應該是檢查首次啓動的理想位置。我希望這是有道理的... – Alladinian
完美!將它放在應用程序委託中似乎可以解決它!非常感謝! (爲什麼不作爲答案提交?:D) – jskidd3
完成。很高興這有助於你:) – Alladinian