NSMakeCollectable and ARC doesn't work

后端 未结 5 1051
故里飘歌
故里飘歌 2020-12-16 10:46

I\'m trying to convert my old project to ARC. I have a function which creates UUIDs, but apparently this is no longer supported when using ARC:

NSString *uui         


        
5条回答
  •  一整个雨季
    2020-12-16 11:43

    To have a single UUID across whole app, I think the best way to achieve that would be to have it run once in the whole application lifecycle.

    static NSString *uuid;
    - (NSString *)theCurrentDeviceUniqueIdentifier {
    
        static dispatch_once_t onceToken;
        dispatch_once(&onceToken, ^{
            CFUUIDRef theUUID = CFUUIDCreate(kCFAllocatorDefault);
            if (theUUID) {
                uuid = CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, theUUID));
                CFRelease(theUUID);
            }
        });
    
        return uuid;
    }
    

提交回复
热议问题