当前位置:网站首页>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
边栏推荐
- hdu 4912 Paths on the tree(lca+馋)
- 1292_ Implementation analysis of vtask resume() and xtask resume fromisr() in freeros
- 美国科技行业结束黄金时代,芯片求售、裁员3万等哀声不断
- 小满网络模型&http1-http2 &浏览器缓存
- Some problems about the use of char[] array assignment through scanf..
- 袁小林:安全不只是标准,更是沃尔沃不变的信仰和追求
- make menuconfig出现recipe for target ‘menuconfig‘ failed错误
- JPEG2000 matlab source code implementation
- Comparison between multithreaded CAS and synchronized
- Efficiency tool +wps check box shows the solution to the sun problem
猜你喜欢

美国科技行业结束黄金时代,芯片求售、裁员3万等哀声不断

Checkpoint of RDD in spark

bat脚本学习(一)

Earned value management EVM detailed explanation and application, example explanation
![Some problems about the use of char[] array assignment through scanf..](/img/cf/d85a3172c5d29ac00377f9c30dbc4f.png)
Some problems about the use of char[] array assignment through scanf..

【sciter】: 基于 sciter 封装通知栏组件

Why is the cluster mode of spark on Yan better than the client mode

Microsoft technology empowerment position - February course Preview

Aggregate function with key in spark

GPS从入门到放弃(十九)、精密星历(sp3格式)
随机推荐
Technology sharing | packet capturing analysis TCP protocol
Z function (extended KMP)
Happy sound 2[sing.2]
Some problems about the use of char[] array assignment through scanf..
Numpy download and installation
MariaDb数据库管理系统的学习(一)安装示意图
一行代码可以做些什么?
jvm:大对象在老年代的分配
Reinforcement learning - learning notes 5 | alphago
ViT论文详解
Leveldb source code analysis series - main process
C language: comprehensive application of if, def and ifndef
设置状态栏样式Demo
ROS error: could not find a package configuration file provided by "move_base“
Run the deep network on PI and Jetson nano, and the program is killed
The underlying implementation of string
强化学习-学习笔记5 | AlphaGo
抖音將推獨立種草App“可頌”,字節忘不掉小紅書?
PostgreSQL 安装gis插件 CREATE EXTENSION postgis_topology
OpenCV300 CMake生成project在项目过程中的问题