Generate a UUID string with ARC enabled

后端 未结 3 802
春和景丽
春和景丽 2020-12-04 09:20

I need to generate a UUID string in some code with ARC enabled.

After doing some research, this is what I came up with:

CFUUIDRef uuid = CFUUIDCreate         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-04 09:35

    That looks correct to me.

    You have CFRelease'd uuid, which is your responsibility from the CFUUIDCreate()

    And you've transferred ownership of the string to ARC, so the compiler knows to release uuidStr at the appropriate time.

提交回复
热议问题