Sheshnath
Sheshnath

Reputation: 3393

NSString to NSUUID convert

how to convert from NSString to NSUUID ? i got the answer for conversion of, NSUUID to NSString but vice versa could not found.like this is my string @"12033030303" alloc NSUUID using this string any help would be appreciated

Upvotes: 13

Views: 7447

Answers (1)

l0gg3r
l0gg3r

Reputation: 8954

@"12033030303" is not possible to convert to NSUUID, as Universally Unique Identifier has specification (for example look at wikipedia), this means any random string can't be converted to NSUUID.

initWithUUIDString should be the method you're looking for, but it works only if UUID is valid.

NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"A5D59C2F-FE68-4BE7-B318-95029619C759"];

Upvotes: 22

Related Questions