当前位置:网站首页>Save and retrieve strings
Save and retrieve strings
2022-07-06 21:57:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack .
Sometimes , Some things need to be stored on the phone , For example , stay APP Storage and use time considerations password what
Several examples of methods need to be written
stay .h Write the French name above in the document
+ (void) saveCenterProValue:(NSString*)valueStr key:(NSString *)keyStr;
+ (id)getCenterPro:(NSString*)identifier;
stay .m Add the implementation method to the file
ps: It is better to write in a single example
+ (void) saveCenterProValue:(NSString*)valueStr key:(NSString *)keyStr{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:valueStr forKey:keyStr];
[defaults synchronize];
}
+ (id)getCenterPro:(NSString*)identifier{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
return [defaults objectForKey:identifier];
}
Okay , That's it
Next . How to use this method
1. Use a macro to define
#define UserPass @“UserPass” // user password
#define UserID @“UserID” // user ID
2. Save a string
[Common saveCenterProValue:@”123456″ key:UserPass];
[Common saveCenterProValue:@”001″ key:UserID];
3. Get this string
Common getCenterPro:UserPass];
Common getCenterPro:UserID];
Copyright notice : This article is the original article of the blogger , Blog , Do not reprint without permission .
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/117073.html Link to the original text :https://javaforall.cn
边栏推荐
- High precision face recognition based on insightface, which can directly benchmark hongruan
- GPS从入门到放弃(十一)、差分GPS
- Shell product written examination related
- [Digital IC manual tearing code] Verilog automatic beverage machine | topic | principle | design | simulation
- Redistemplate common collection instructions opsforhash (IV)
- 爬虫实战(五):爬豆瓣top250
- SQL:存储过程和触发器~笔记
- 新入职一家公司需要去实践和注意的内容
- Why rdd/dataset is needed in spark
- C# 如何在dataGridView里设置两个列comboboxcolumn绑定级联事件的一个二级联动效果
猜你喜欢
uni-app App端半屏连续扫码
The golden age of the U.S. technology industry has ended, and there have been constant lamentations about chip sales and 30000 layoffs
Tiktok will push the independent grass planting app "praiseworthy". Can't bytes forget the little red book?
Leetcode learning records (starting from the novice village, you can't kill out of the novice Village) ---1
LeetCode:1189. The maximum number of "balloons" -- simple
Make menuconfig has a recipe for target 'menuconfig' failed error
AI 企业多云存储架构实践 | 深势科技分享
Summary of cross partition scheme
关于程序员的职业操守,从《匠艺整洁之道》谈起
一行代码可以做些什么?
随机推荐
GPS从入门到放弃(十四)、电离层延时
功能强大的国产Api管理工具
Bat script learning (I)
设置状态栏样式Demo
Redistemplate common collection instructions opsforhash (IV)
华为在多个行业同时出击,吓人的技术让欧美企业瑟瑟发抖
数字化转型挂帅复产复工,线上线下全融合重建商业逻辑
语谱图怎么看
关于程序员的职业操守,从《匠艺整洁之道》谈起
Hill | insert sort
Run the deep network on PI and Jetson nano, and the program is killed
Reset Mikrotik Routeros using netinstall
The underlying implementation of string
十一、服务介绍及端口
make menuconfig出现recipe for target ‘menuconfig‘ failed错误
1292_ Implementation analysis of vtask resume() and xtask resume fromisr() in freeros
14 years Bachelor degree, transferred to software testing, salary 13.5k
Summary of cross partition scheme
Yyds dry goods inventory C language recursive implementation of Hanoi Tower
guava:Collections.unmodifiableXXX创建的collection并不immutable