- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
// Override point for customization after application launch.
_window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
[_window setBackgroundColor:[UIColor whiteColor]];
//==========手机数据本地化=========================
//OC中学到的数据本地化技术在ios中都适用,只是注意路径问题
//ios应用程序,在手机上都有一个独立的内存空间专门用来存储当前这个应用程序的
//数据;每个应用程序对应的内存空间只能当前应用去访问内存空间
//这个内存叫"沙盒";
//ios数据本地化就是将数据存到沙盒目录下;
//2.每个沙盒目录最外层固定有三个文件夹,分别是
//documents,library,tmp,其中library下面还有caches和preferences两个文件夹;
//每个文件夹存储不一样的数据
//douments:专门存储在程序中生成的文件:数据库文件
//存储在documents文件夹的数据除非删除程序或者通过代码强制删除
//否则一直存在;(就算是更新应用程序这个文件夹的内容也会被备份)
//Caches:在这个文件夹中专门用来存储缓存数据,(缓存图片)
//更新应用程序的时候,这个文件夹的内容不会被备份
//如果应用程序中实现清除缓存功能的实质就是删除这个文件夹的内容
//Preferences:这个文件夹中用来存储一些设置性的数据(plist文件)
//应用程序更新的时候不会被备份但是也不会删除;
//tmp:用来存储临时文件,这个文件夹的内容,每次程序运行结束后都会被删除;
//1.获取沙盒主目录(如果应用程序运行在模拟器上,获取到得就是模拟器的沙盒路径
//运行在真机上就是真机的沙盒目录);
NSString *path = NSHomeDirectory();
//2.拿到沙盒子目录
NSString *documentspath = [path stringByAppendingPathComponent:
@"Documents"];
NSString *Librarypath = [path stringByAppendingPathComponent:@"Library"];
NSLog(@"%@",Librarypath);
// NSArray *pathArray = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);
// NSLog(@"%@",pathArray[0]);
//================NSUserDafults=============================
//实质就是操作一个plist文件;
//1.拿到NSUserDefaults的单例对象,指向的是当前这个应用程序本地
//里面一个和NSUserDefaults相关联的plist文件
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
//2.往NSUserDefaults中存储数据(键值对的形式)
//如果之前没有以相同的键去存过数据,那么数据就会存到plist中
//否则将会被覆盖
//a.以键值对的形式存储对象(NSArray,NSDictionary,NSString,NSdata)到本地
setObject:@"luhan" forKey:@"鹿晗"];
//b.存储整型数据
setInteger:420 forKey:@"birthday"];
setFloat:77.0 forKey:@"luckynumber"];
setBool:YES forKey:@"idol"];
//3.从NSUserDefaults中取数据
NSLog(@"%@", [defaults objectForKey:@"birthday"]);
NSLog(@"%f", [defaults floatForKey:@"luckynumber"]);
NSLog(@"%d", [defaults boolForKey:@"idol"]);
[_window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end