snn5love11314的专栏

UUID一般只生成一次,保存在iOS系统里面,如果应用删除了,重装应用之后它的UUID还是一样的,除非系统重置 。但是不能保证在以后的系统升级后还能用(如果系统保存了该信息就能用).由于IOS系统存储的数据都是在sandBox里面,一旦删除App,sandBox也不复存在。好在有一个例外,那就是keychain(钥匙串)。通常情况下,IOS系统用NSUserDefaults存储数据信息,但是对于一些私密信息,比如密码、证书等等,就需要使用更为安全的keychain了。iOS的keychain服务提供了一种安全的保存私密信息(密码,序列号,证书等)的方式,每个ios程序都有一个独立的keychain存储。相对于NSUserDefaults、文件保存等一般方式,keychain保存更为安全,而且keychain里保存的信息不会因App被删除而丢失,,所以在重装App后,keychain里的数据还能使用。从ios 3。0开始,跨程序分享keychain变得可行。如何需要在应用里使用使用keyChain,我们需要导入Security.framework ,keychain的操作接口声明在头文件SecItem.h里。直接使用SecItem.h里方法操作keychain,需要写的代码较为复杂,为减轻咱们程序员的开发,我们可以使用一些已经封装好了的工具类,下面我会简单介绍下我用过的两个工具类:KeychainItemWrapper和SFHFKeychainUtils。

/* File: KeychainItemWrapper.hAbstract: Objective-C wrapper for accessing a single keychain item. Version: 1.2Disclaimer: IMPORTANT: This Apple software is supplied to you by AppleInc. ("Apple") in consideration of your agreement to the followingterms, and your use, installation, modification or redistribution ofthis Apple software constitutes acceptance of these terms. If you donot agree with these terms, please do not use, install, modify orredistribute this Apple software.In consideration of your agreement to abide by the following terms, andsubject to these terms, Apple grants you a personal, non-exclusivelicense, under Apple’s copyrights in this original Apple software (the"Apple Software"), to use, reproduce, modify and redistribute the AppleSoftware, with or without modifications, in source and/or binary forms;provided that if you redistribute the Apple Software in its entirety andwithout modifications, you must retain this notice and the followingtext and disclaimers in all such redistributions of the Apple Software.Neither the name, trademarks, service marks or logos of Apple Inc. maybe used to endorse or promote products derived from the Apple Softwarewithout specific prior written permission from Apple. Except asexpressly stated in this notice, no other rights or licenses, express orimplied, are granted by Apple herein, including but not limited to anypatent rights that may be infringed by your derivative works or by otherworks in which the Apple Software may be incorporated.The Apple Software is provided by Apple on an "AS IS" basis. APPLEMAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATIONTHE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESSFOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE ANDOPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTALOR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OFSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESSINTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSEDAND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THEPOSSIBILITY OF SUCH DAMAGE.Copyright (C) 2010 Apple Inc. All Rights Reserved.*/#import <UIKit/UIKit.h>/* The KeychainItemWrapper class is an abstraction layer for the iPhone Keychain communication. It is merely a simple wrapper to provide a distinct barrier between all the idiosyncracies involved with the Keychain CF/NS container objects.*/@interface KeychainItemWrapper : NSObject{ NSMutableDictionary *keychainItemData; // The actual keychain item data backing store. NSMutableDictionary *genericPasswordQuery; // A placeholder for the generic keychain item query used to locate the item.}@property (nonatomic, retain) NSMutableDictionary *keychainItemData;@property (nonatomic, retain) NSMutableDictionary *genericPasswordQuery;// Designated initializer.- (id)initWithIdentifier: (NSString *)identifier accessGroup:(NSString *) accessGroup;- (void)setObject:(id)inObject forKey:(id)key;- (id)objectForKey:(id)key;// Initializes and resets the default generic keychain item data.- (void)resetKeychainItem;@end

望着它们,我睡着了。今天已经过去——我生命中所有天中的一天,

snn5love11314的专栏

相关文章:

你感兴趣的文章:

标签云: