坚持 成长 每日一篇
在开发过程中我们有时候在用户删除时候保存一些信息在用户下次安装应用时候使用,这个时候我们可以使用剪切版UIPasteboard的FindUIPasteboard和钥匙串keychain的使用
剪切版
剪切版主要分为以下两种
UIPasteboardNameGeneral和UIPasteboardNameFind
两种都是系统级的可以在应用删除后仍然保留数据
开发中我们常常使用UIPasteboard的Find UIPasteboard来保存一些用户删除应用后需要保留的数据如UUID,用户名,密码等
下面是一个保存uuid到UIPasteboard的代码
创建UDID
+ (NSString*) _uuidCreateNewUDID {
NSString* _openUDID = nil;
CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
CFStringRef cfstring = CFUUIDCreateString(kCFAllocatorDefault, uuid);
const char *cStr = CFStringGetCStringPtr(cfstring, CFStringGetFastestEncoding(cfstring));
unsigned char result[16];
CC_MD5(cStr, (unsigned int)strlen(cStr), result);
CFRelease(uuid);
_openUDID = [NSString stringWithFormat:
@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%08x",
result[0], result[1], result[2], result[3],
result[4], result[5], result[6], result[7],
result[8], result[9], result[10], result[11],
result