所以我正在制作一个应用程序和一个页面,用户将输入用户名和密码。它将存储在一个字符串中。假设此字符串存储在 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/