当前位置: 首页 > news >正文

网站国内空间和国外空间网站服务器租金

网站国内空间和国外空间,网站服务器租金,网上教学网站建设,跨境电商是什么意思在开发中#xff0c;如果使用plist存贮到本地的话#xff0c;存贮的类型有限#xff0c;这时候#xff0c;我们可以就可以考虑利用NSKeyedUnarchiver把数据存储到本地#xff0c;通过这个方法我们可以将model存贮到本地#xff0c;一般用来保存用户的账号信息之类的 第一…在开发中如果使用plist存贮到本地的话存贮的类型有限这时候我们可以就可以考虑利用NSKeyedUnarchiver把数据存储到本地通过这个方法我们可以将model存贮到本地一般用来保存用户的账号信息之类的 第一步我们建一个model #import Foundation/Foundation.h interface Account : NSObject property (nonatomic, copy) NSString *phone; //手机号 property (nonatomic, copy) NSString *uid; //用户id property (nonatomic, copy) NSString *nickname; property (nonatomic, copy) NSString *password; property (nonatomic, copy) NSString *tel; //座机 property (nonatomic, copy) NSString *last_login; //property (nonatomic, copy) NSString *new_phone; property (nonatomic, copy) NSString *uthumb; //头像地址 property (nonatomic, copy) NSString *province; property (nonatomic, copy) NSString *city; property (nonatomic, copy) NSString *area; property (nonatomic, copy) NSData *photoData; end #import Account.h implementation Account (NSDictionary *)replacedKeyFromPropertyName { return {uid: id}; } end //定义一个 .h 头文件用来简写我们的单例 // .h #define single_interface(class)  (class *)shared##class; // \ 代表下一行也属于宏 // ## 是分隔符 #define single_implementation(class) \ static class *_instance; \ \ (class *)shared##class \ { \ if (_instance nil) { \ _instance [[self alloc] init]; \ } \ return _instance; \ } \ \ (id)allocWithZone:(NSZone *)zone \ { \ static dispatch_once_t onceToken; \ dispatch_once(onceToken, ^{ \ _instance [super allocWithZone:zone]; \ }); \ return _instance; \ } 第二步封装一个方法使用NSKeyedUnarchiver保存到本地 //  AccountTool.h // #import Foundation/Foundation.h #import Account.h #import SingleTon.h interface AccountTool : NSObject single_interface(AccountTool) - (void)saveAccount:(Account *)account; - (void)removeAccount; // 获得当前账号 property (nonatomic, readonly) Account *account; end // //  AccountTool.m // #import AccountTool.h // 文件路径----获取分类的沙盒文件路径 #define kFile [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0] stringByAppendingPathComponent:account.data] implementation AccountTool single_implementation(AccountTool) - (instancetype)init { if (self [super init]) { //解归档该路径下的文件 _account [NSKeyedUnarchiver unarchiveObjectWithFile:kFile]; } return self; } - (void)saveAccount:(Account *)account { _account account; //将数据归档,如果前面的文件不存在就会在归档数据时创建 [NSKeyedArchiver archiveRootObject:account toFile:kFile]; } - (void)removeAccount { if ([[NSFileManager defaultManager] fileExistsAtPath:kFile]) { [[NSFileManager defaultManager]removeItemAtPath:kFile error:nil]; } } end //这样我们就可以使用这个工具类了下面以保存登录后的账号为例说明如何使用 判断是否有数据 if ([AccountTool sharedAccountTool].account.uid nil || ! kUserLogin || [[AccountTool sharedAccountTool].account.uid isKindOfClass:[NSNull class]]){ //无数据 }else { //有数据 } //登录成功后将数据用mj工具类将字典直接保存到model中然后直接保存到本地 Account *currentAccount [Account mj_objectWithKeyValues:userInfo]; [[AccountTool sharedAccountTool] saveAccount:currentAccount]; //
http://www.zqtcl.cn/news/655679/

相关文章:

  • 使用循环视频做背景的网站青岛网站推广的价格
  • 邯山区建设局网站上海公司招聘
  • 做网站沈阳本地网站忧化 优帮云
  • 网上购物网站开发的目的建筑投标网站
  • 网站开发费用无形资产陕西省住房和城乡建设网站
  • 网站分析与优化如何编程写代码
  • 专业做网站企业百度站长管理平台
  • 网站组建 需求分析阿里巴巴网站装修
  • 网站建设怎么弄轮换图片网站制作公司dedecms
  • 南阳企业网站建设做兼职网站有哪些
  • ps做网站的优点国际设计师网站有哪些
  • 学校网站建立安阳市网站建设
  • 邢台做网站流程摄影工作室网站设计
  • 掉关键词网站重大军事新闻
  • 建材网站建设功能方案上海建筑室内设计有限公司
  • 高端企业网站设计公司怎么帮公司做网站建设
  • 湖北专业网站建设维修电话企业网络管理方案
  • 做网站外链wordpress网页怎么上传
  • wordpress站点优化石景山网站开发
  • 企业网站建设的流程店铺推广引流
  • 北京网站优化wyhseo信息化建设杂志社官方网站
  • 网站图片处理方案动漫制作这个专业怎么样
  • 做写手哪个网站好黄页网站建设黄页网站建设
  • 多语言企业网站免费模板网站哪个好
  • 拟一份饰品网站建设合同襄樊门户网站建设
  • 你对网站第一印象受欢迎的广州做网站
  • 网站开发项目的需求分析浙江省城乡建设网站证件查询
  • 整站seo定制简单 大气 网站模版
  • 网站界面设计策划书怎么做云匠网订单多吗
  • html教程 pdf网站建设优化兰州