获取UUID

    if ([[NSUserDefaults standardUserDefaults]objectForKey:@"UUID"]==nil) {

        CFUUIDRef uuid = CFUUIDCreate(NULL);

        CFStringRef uuidstring = CFUUIDCreateString(NULL, uuid);

        // 就下面这个玩意

        NSString *identifierNumber = [NSString stringWithFormat:@"%@",uuidstring];

        // 存起来以后用

        [[NSUserDefaults standardUserDefaults] setObject:identifierNumber forKey:@"UUID"];

        [[NSUserDefaults standardUserDefaults] synchronize];

        CFRelease(uuidstring);

        CFRelease(uuid);

    }

    NSLog(@"%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"UUID"]);


你可能感兴趣的:(iOS笔记)