美文网首页
开发所得(一)

开发所得(一)

作者: hzy1314 | 来源:发表于2017-07-21 18:20 被阅读5次

[[UIApplication sharedApplication] setIdleTimerDisabled:YES];//不锁屏

https://github.com/CoderZhuXH/XHLaunchAd

[[[self.contentSize componentsSeparatedByString:@"*"] firstObject] floatValue] //通过字符串中字符进行截取字段

沙盒中只能保存OC中的基本数据,自定义的对象不能直接存入。 存入方式如下。

//    1,获取家目录路径的函数://    NSString *homeDir = NSHomeDirectory();//    2,获取Documents目录路径的方法://    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);//    NSString *docDir = [paths objectAtIndex:0];//    3,获取Caches目录路径的方法:    NSArray *paths =NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);    NSString *cachesDir = [paths objectAtIndex:0];//    4,获取tmp目录路径的方法://    NSString *tmpDir = NSTemporaryDirectory();        //假设我们需往cache 存入数据,并命名为test的txt格式文件中    NSString *filePath = [cachesDir stringByAppendingPathComponent:@"test.txt"];    NSArray *dic = [[NSArray alloc] initWithObjects:@"test",@"test1",nil];        if([dic writeToFile:filePath atomically:YES]){        NSLog(@"存入成功");

}

//取出数据 打印

NSLog(@"%@",[NSArray arrayWithContentsOfFile:filePath]);

相关文章

网友评论

      本文标题: 开发所得(一)

      本文链接:https://www.haomeiwen.com/subject/bokyhxtx.html