当前位置:网站首页>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
边栏推荐
- 美国科技行业结束黄金时代,芯片求售、裁员3万等哀声不断
- Caching strategies overview
- JS learning notes OO create suspicious objects
- Oracle性能分析3:TKPROF简介
- [Yu Yue education] reference materials for surgical skills teaching in Tongji University
- GPS从入门到放弃(十一)、差分GPS
- Internet News: Geely officially acquired Meizu; Intensive insulin purchase was fully implemented in 31 provinces
- 新入职一家公司需要去实践和注意的内容
- The underlying implementation of string
- numpy 下载安装
猜你喜欢
20 large visual screens that are highly praised by the boss, with source code templates!
中国白酒的5场大战
GPS从入门到放弃(十四)、电离层延时
uni-app App端半屏连续扫码
GPS从入门到放弃(十三)、接收机自主完好性监测(RAIM)
Earned value management EVM detailed explanation and application, example explanation
Aggregate function with key in spark
Leetcode topic [array] -118 Yang Hui triangle
What can one line of code do?
美国科技行业结束黄金时代,芯片求售、裁员3万等哀声不断
随机推荐
华为在多个行业同时出击,吓人的技术让欧美企业瑟瑟发抖
Binary tree node at the longest distance
Why is the cluster mode of spark on Yan better than the client mode
Sdl2 source analysis 7: performance (sdl_renderpresent())
C语言:#if、#def和#ifndef综合应用
新入职一家公司需要去实践和注意的内容
PostgreSQL install GIS plug-in create extension PostGIS_ topology
Codeforces Round #274 (Div. 2) –A Expression
【sciter】: 基于 sciter 封装通知栏组件
make menuconfig出现recipe for target ‘menuconfig‘ failed错误
Depth first traversal (DFS) and breadth first traversal (BFS)
[Chongqing Guangdong education] Tianjin urban construction university concrete structure design principle a reference
Bat script learning (I)
Redistemplate common collection instructions opsforlist (III)
PostgreSQL 安装gis插件 CREATE EXTENSION postgis_topology
Leetcode learning records (starting from the novice village, you can't kill out of the novice Village) ---1
GPS从入门到放弃(十二)、 多普勒定速
Enhance network security of kubernetes with cilium
Z function (extended KMP)
Yyds dry goods inventory C language recursive implementation of Hanoi Tower