int
healthInt
에서 2를 뺀 방법이 있습니다. 그런 다음 healthString
이라는 NSString
이 표시되고 이는 healthInt
으로 표시됩니다. 그래서이 방법에서 내가하고 싶은 것은 take2Damage
입니다. healthInt
에서 2를 뺍니다. healthLabel
을 UILabel
으로 설정할 경우 healthString
으로 설정하십시오. 문제는 다른 클래스에있는 healthLabel
입니다. 여기에 몇 가지 코드가 있습니다.AppDelegate.m의 다른 클래스에서 UILabel에 액세스
Appdelegate.m
-(void)take2Damage{
healthInt = healthInt - 2;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
healthInt = 100;
healthString = [[NSString alloc]initWithFormat:@"%d", healthInt];
LevelOneViewController.m
IBOutlet UILabel * healthLabel;
작동하지 않는 것을 말하지 않았습니다. – jrturton