Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UUID from string always nil

Tags:

ios

swift

I try to parse UUID from string but it's always nil. I write it like this.

UUID(uuidString: "my UUID")

I even try it like this in xcode expression watcher but it's also nil

UUID(uuidString: UUID().uuidString)

But when I try NSUUID on the same string, It's working fine.

NSUUID(uuidString: "my UUID") 

Did anyone know what should I check? or is there anyway to convert from NSUUID to UUID?

Thank you very much in advance.

like image 825
LLF Avatar asked Oct 25 '25 19:10

LLF


1 Answers

I try to parse UUID from string but it's always nil. I write it like this.

UUID(uuidString: "my UUID") -> 

reason

The standard format for UUIDs represented in ASCII is a string punctuated by hyphens, for example 68753A44-4D6F-1226-9C60-0050E4C00067.

Returns nil for invalid strings.

I even try it like this in Xcode expression watcher but it's also nil

UUID(uuidString: UUID().uuidString) -> it is returning a UUID like (7AFD7082-7A14-44F8-B839-5C4D98842798), working fine 
like image 143
SGDev Avatar answered Oct 28 '25 11:10

SGDev