This question already has answers here:
How to check the validity of a GUID (or UUID) using NSRegularExpression or any other effective way in Objective-C
                                
                                    (4个答案)
                                
                        
                                在11个月前关闭。
            
                    
当我使用[CBUUID UUIDWithString:@"xxx"](类似无效的uuid字符串)时,应用程序将崩溃。
如何检查参数是否为有效的UUID格式。

错误是:


  -[CBUUID initWithString:],/ BuildRoot / Library / Caches / com.apple.xbs / Sources / MobileBluetoothFramework / MobileBluetooth-115.5.1 / CoreBluetooth / CoreBluetooth / CBUUID.m:149中的声明失败


我不明白为什么断言会在发行版上发生。也许苹果忘记了关闭断言开关。

最佳答案

尝试这个:

-(BOOL)isUUID:(NSString *)string
{
   return !![[NSUUID alloc] initWithUUIDString:string];
}

关于ios - 输入无效的参数时,UUIDWithString崩溃,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55133524/

10-12 01:41