Skip to content

Instantly share code, notes, and snippets.

@cuberoot
Created July 22, 2010 23:06
Show Gist options
  • Save cuberoot/486765 to your computer and use it in GitHub Desktop.
Save cuberoot/486765 to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
@interface NSString (UUID)
+ (NSString*)stringWithUUID;
@end
#import "NSString+UUID.h"
@implementation NSString (UUID)
+ (NSString*)stringWithUUID
{
CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
NSString * string = (NSString*)CFMakeCollectable(CFUUIDCreateString(kCFAllocatorDefault, uuid));
CFRelease(uuid);
return [string autorelease];
}
@end
@cuberoot
Copy link
Author

Simple category for adding a method to NSString for creating UUID's

@Abizern
Copy link

Abizern commented Dec 20, 2011

For an ARC compatible implementation: https://gist.github.com/1501325

Although this is a method, not an extension to NSString.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment