How to check the validity of a GUID (or UUID) using NSRegularExpression or any other effective way in Objective-C

后端 未结 4 524
滥情空心
滥情空心 2021-01-12 08:58

The method should return TRUE if the NSString is something like @\"{A5B8A206-E14D-429B-BEB0-2DD0575F3BC0}\" and FALSE for a NSString like @\"bla bla bla\"

I am using

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-12 09:13

    This function will do the job..

    -(BOOL)isValidUUID : (NSString *)UUIDString
    {
         return (bool)[[NSUUID alloc] initWithUUIDString:U‌​UIDString]; 
    }
    

    Thanks @Erzékiel

提交回复
热议问题