Permalink
Browse files

Renamed MCSMUUIDKeychainItemService to MCSMApplicationUUIDKeychainItem

  • Loading branch information...
ObjColumnist committed Apr 6, 2012
1 parent 0aa4e64 commit 6cd93582f2fa0e9f0d805e43844b071ddbef2e20
Showing with 18 additions and 18 deletions.
  1. +4 −4 MCSMKeychainItem.h
  2. +7 −7 MCSMKeychainItem.m
  3. +7 −7 README.mdown
View
@@ -45,14 +45,14 @@
@end
-extern NSString *const MCSMUUIDKeychainItemService;
+extern NSString *const MCSMApplicationUUIDKeychainItemService;
-@interface MCSMUUIDKeychainItem : MCSMGenericKeychainItem
+@interface MCSMApplicationUUIDKeychainItem : MCSMGenericKeychainItem
@property (readonly, copy) NSString *UUID;
-+ (MCSMUUIDKeychainItem *)generateApplicationUUIDKeychainItem;
-+ (MCSMUUIDKeychainItem *)applicationUUIDKeychainItem;
++ (MCSMApplicationUUIDKeychainItem *)generateApplicationUUIDKeychainItem;
++ (MCSMApplicationUUIDKeychainItem *)applicationUUIDKeychainItem;
+ (NSString *)applicationUUID;
View
@@ -540,32 +540,32 @@ + (MCSMGenericKeychainItem *)genericKeychainItemWithService:(NSString *)service
@end
-NSString *const MCSMUUIDKeychainItemService = @"com.squarebracketsoftware.opensource.keychain.uuid.application";
+NSString *const MCSMApplicationUUIDKeychainItemService = @"com.squarebracketsoftware.opensource.keychain.uuid.application";
-@implementation MCSMUUIDKeychainItem
+@implementation MCSMApplicationUUIDKeychainItem
-+ (MCSMUUIDKeychainItem *)generateApplicationUUIDKeychainItem{
++ (MCSMApplicationUUIDKeychainItem *)generateApplicationUUIDKeychainItem{
CFUUIDRef UUIDRef = CFUUIDCreate(kCFAllocatorDefault);
CFStringRef UUIDStringRef = CFUUIDCreateString(kCFAllocatorDefault, UUIDRef);
NSString *UUIDString = [NSString stringWithString:(NSString *)UUIDStringRef];
CFRelease(UUIDStringRef);
CFRelease(UUIDRef);
- return (MCSMUUIDKeychainItem *)[self genericKeychainItemWithService:MCSMUUIDKeychainItemService
+ return (MCSMApplicationUUIDKeychainItem *)[self genericKeychainItemWithService:MCSMApplicationUUIDKeychainItemService
username:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]
password:UUIDString];
}
-+ (MCSMUUIDKeychainItem *)applicationUUIDKeychainItem{
++ (MCSMApplicationUUIDKeychainItem *)applicationUUIDKeychainItem{
- return (MCSMUUIDKeychainItem *)[self genericKeychainItemForService:MCSMUUIDKeychainItemService
+ return (MCSMApplicationUUIDKeychainItem *)[self genericKeychainItemForService:MCSMApplicationUUIDKeychainItemService
username:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]];
}
+ (NSString *)applicationUUID{
- MCSMUUIDKeychainItem *applicationUDIDKeychainItem = [self applicationUUIDKeychainItem];
+ MCSMApplicationUUIDKeychainItem *applicationUDIDKeychainItem = [self applicationUUIDKeychainItem];
if(!applicationUDIDKeychainItem)
{
View
@@ -32,33 +32,33 @@ And to *remove* it from the Keychain just call removeFromKeychain:
[keychainItem removeFromKeychain];
-## MCSMUUIDKeychainItem
+## MCSMApplicationUUIDKeychainItem
Apple have deprecated the unique identifier API that returns the *UDID* for a device in iOS 5.0.
You can however generate a *UUID* using the CoreFoundation's `CFUUIDCreateString` API
The important thing to realize about `CFUUIDCreateString` is that (by design) it generates a different *UUID* everytime you call it. This means that you cannot uniquely identify a device by simply replacing `[UIDevice uniqueIdentifier]` with `CFUUIDCreateString`.
-*MCSMUUIDKeychainItem's* approach is to generate a *UUID* on first call of the API and then store the *UUID* into the device's keychain. This means that the *UUID* will not change between launches of the application and storing it in the keychain means it persists between reinstalls of the application. However the *UUID* will be deleted if the user restores their device, along with every other keychain item.
+*MCSMApplicationUUIDKeychainItem's* approach is to generate a *UUID* on first call of the API and then store the *UUID* into the device's keychain. This means that the *UUID* will not change between launches of the application and storing it in the keychain means it persists between reinstalls of the application. However the *UUID* will be deleted if the user restores their device, along with every other keychain item.
-If all you need is a replacement for *UIDevice's* `uniqueIdentifier` API, then all you need to do replace it with *MCSMUUIDKeychainItem's* `applicationUUID` API.
+If all you need is a replacement for *UIDevice's* `uniqueIdentifier` API, then all you need to do replace it with *MCSMApplicationUUIDKeychainItem's* `applicationUUID` API.
- NSString *UUID = [MCSMUUIDKeychainItem applicationUUID];
+ NSString *UUID = [MCSMApplicationUUIDKeychainItem applicationUUID];
The first time `applicationUUID` is called it with generate a UUID and store it in the keychain. Subsequent calls will return the previously generated *UUID*.
-If you need more control you can retrieve the *UUID* Keychain Item using:
+If you need more control you can retrieve the Application UUID Keychain Item using:
- MCSMUUIDKeychainItem *applicationUUIDKeychainItem = [MCSMUUIDKeychainItem applicationUUIDKeychainItem];
+ MCSMApplicationUUIDKeychainItem *applicationUUIDKeychainItem = [MCSMApplicationUUIDKeychainItem applicationUUIDKeychainItem];
Then you can get the *UUID* using the *UUID* property:
NSString *UUID = applicationUUIDKeychainItem.UUID
If one doesn't exist you can generate one:
- MCSMUUIDKeychainItem *applicationUUIDKeychainItem = [MCSMUUIDKeychainItem generateApplicationUUIDKeychainItem];
+ MCSMApplicationUUIDKeychainItem *applicationUUIDKeychainItem = [MCSMApplicationUUIDKeychainItem generateApplicationUUIDKeychainItem];
And you can remove it using:

2 comments on commit 6cd9358

@jazzbox

This comment has been minimized.

Show comment Hide comment
@jazzbox

jazzbox Apr 10, 2012

Why do you call it ApplicationUUID and not DeviceUUID? A real ApplicationUUID should be synced over iCloud across devices IMHO...

Why do you call it ApplicationUUID and not DeviceUUID? A real ApplicationUUID should be synced over iCloud across devices IMHO...

@ObjColumnist

This comment has been minimized.

Show comment Hide comment
@ObjColumnist

ObjColumnist Apr 10, 2012

Owner

As different applications will have a different UUID, so it doesn't uniquely identify the device just that application. If you have 2 applications on the device they will generate different UUIDs.

If someone has a better idea for a name then I will change it, but I don't think device is correct either.

Owner

ObjColumnist replied Apr 10, 2012

As different applications will have a different UUID, so it doesn't uniquely identify the device just that application. If you have 2 applications on the device they will generate different UUIDs.

If someone has a better idea for a name then I will change it, but I don't think device is correct either.

Please sign in to comment.