If i have a UILabel saved a time, saved in plist using the below codes. Now i could like to load the time e.g. 1:00am and display the time (1:00am) on a UIPicker in another view controller in the storyboard. How this can be done?
Thanks
- (void)viewDidLoad
{NSString *myPath = [self saveFilePath];
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:myPath];
if (fileExists)
{
NSArray *values = [[NSArray alloc] initWithContentsOfFile:myPath];
morningtime.text = [values objectAtIndex:0];
afternoontime.text = [values objectAtIndex:1];
}
UIApplication *myApp = [UIApplication sharedApplication];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidEnterBackground:)
name:UIApplicationDidEnterBackgroundNotification
object:myApp];
[super viewDidLoad]; }
- (NSString *) saveFilePath
{
NSArray *path =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
return [[path objectAtIndex:0] stringByAppendingPathComponent:@"savefile.plist"];
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
NSArray *values = [[NSArray alloc] initWithObjects:morningtime.text,afternoontime.text,nil];
[values writeToFile:[self saveFilePath] atomically:YES];
}