2011-07-13 11 views
0

私はテストアプリケーションを作っています。今私はアプリケーション内にタイマーを持っていますdidFinishLaunching。ここで別のクラスにサブビューを追加する

は私のコードです:

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
    {  timelabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 80, 280, 120)];  
[self.view addSubview:timelabel]; 
[timelabel.text isEqualToString:@"0"]; 
time = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self  
    selector:@selector(timervoid) userInfo:nil repeats:YES]; 
} 


-(void)timervoid { 
int now; 
now = [timelabel.text intValue]; 
int after; 
after = now + 1; 
timelabel.text = [NSString stringWithFormat:@"%i", after]; 

} 

私はアプリのデリゲートアプリケーションdidFinishLaunchingにそれを置く理由である、すべてのクラスを続行するためにタイマーが必要ですが、どのように私はクラスのビューに追加することができますか?

+0

このリンクはいくつかの役に立つかもしれません... http://stackoverflow.com/questions/2959641/how-can-i-call-nstimer-form-one-viewcontroller-from-unother-viewcontroller – booleanBoy

答えて

1

UIApplication sharedApplicationを使用して、uがappDelegateクラスで宣言したタイマーにアクセスできます。

希望します。

ハッピーコーディング!

+0

どのようにそれをコード化できますか? – user842059

関連する問題