Hello everyone how to create a unique identifier for each iphone device of length 15 characters?
            Asked
            
        
        
            Active
            
        
            Viewed 187 times
        
    2 Answers
0
            Usually developers use CFUUIDRef
 CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
 NSString *uuidString = (NSString *)CFUUIDCreateString(NULL,uuidRef);
 CFRelease(uuidRef);
If you need exactly 15?
You can cut this string:
NSString *resultString = [uuidString substringWithRange: NSMakeRange (0, 15)];
 
    
    
        B.S.
        
- 21,660
- 14
- 87
- 109
- 
                    Hello thanks :) but its possible that when cutting it it can cause duplicate? – veereev Mar 26 '13 at 11:01
- 
                    Of course it can, even not cut string can bu a duplicate, but the chance of it is so small that everyone ignores it. – B.S. Mar 26 '13 at 11:03
-1
            
            
        Apple announced some days ago that apps would be rejected if they keep using the old deprecated uniqueidentifier method:
[[UIDevice currentDevice] uniqueIdentifier];
It must be changed to:
   CFUUIDRef uuid = CFUUIDCreate(NULL);
   CFStringRef uuidStr = CFUUIDCreateString(NULL, uuid);
   CFRelease(uuid);
 
    
    
        apascual
        
- 2,970
- 1
- 20
- 32
- 
                    Although this is unique, it isn't constant. Run it a couple of times and you won't get the same one. So it's utility as associating a user is limited as if the app gets removed and reinstalled, you'll have a completely new and different one. – Abizern Jul 03 '13 at 14:13
