iphone - 多个类 iOS 中的一个字符串

标签 iphone ios string sdk

所以我正在制作一个应用程序和一个页面,用户将输入用户名和密码。它将存储在一个字符串中。假设此字符串存储在 setting.m/.h 文件中。我如何从其他类访问它们?

最佳答案

您应该始终使用钥匙串(keychain)来存储用户名和密码,因为它是安全存储的并且只有您的应用可以访问。参见 Apple 的 GenericKeychain sample code :

This sample shows how to add, query for, remove, and update a keychain item of generic class type. Also demonstrates the use of shared keychain items. All classes exhibit very similar behavior so the included examples will scale to the other classes of Keychain Item: Internet Password, Certificate, Key, and Identity.

如果您想存储其他不敏感的字符串、整数、 float 或数组,那么您应该考虑使用 NSUserDefaults .

关于iphone - 多个类 iOS 中的一个字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8542454/

相关文章:

iphone - Storyboard中制作的 UIScrollView 的帧值为零

c++ - 在 objective-c ++上运行时,字符串函数C++返回空

ios - 如何在相机覆盖层的正中间设置十字线图标?

java - 一次将单个字符串拆分为多个模式

iphone - Dropbox SDK 401 错误

ios - 部署 iPhone 配置文件

iPhone、Cocos2D - 触摸屏幕时左/右移动 Sprite

ios - SceneKit Audio - 如何将 SCNPlayer 添加到 SCNNode 并播放声音

java - 在java中解析货币字符串

c - 如何正确比较命令行参数?