每次启动应用程序时,我都想更改屏幕上的文本。该方法被调用,但文本没有改变。
myAppDelegate.m
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:-1];
viewController *object = [[viewController alloc] init];
[object methodA];
}
视图控制器.m
-(void)methodA{
//Create an URL pointing to your plist
NSURL *plistURL = [[NSBundle mainBundle] URLForResource: @"myPlist" withExtension: @"plist"];
//Read the plist from the application bundle into an array object.
NSArray *stringsArray = [NSArray arrayWithContentsOfURL: plistURL];
//Create a random index into the array
NSUInteger randomIndex = arc4random_uniform(stringsArray.count);
//Fetch the string at that random index
NSString *randomString = stringsArray[randomIndex];
//Set some label's text to the random string.
_myLabel.text = randomString;
NSLog(@"methodA");
}
我在我的日志中得到“methodA”。