IOS How to gen uuid

- (NSString *) genUUID{
    // >= iOS6 return identifierForVendor
    UIDevice *device = [UIDevice currentDevice];
   
    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {
        if ([device respondsToSelector:@selector(identifierForVendor)] && [NSUUID class]) {
            NSUUID *uuid = [device identifierForVendor];
            return [[uuid UUIDString] stringFromMD5];
        }
    } else {
            NSString *macaddress = [[UIDevice currentDevice] macaddress];
        NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
       
        NSString *stringToHash = [NSString stringWithFormat:@"%@%@",macaddress,bundleIdentifier];
        NSString *uniqueIdentifier = [stringToHash stringFromMD5];
       
        return uniqueIdentifier;
    }
   
    return @"";
}

Comments

Popular posts from this blog

LINUX Move and copy files using SSH

PHP Predefined Variables

Java : Variables Declaring