URL Validation (Objective-C)

前端 未结 4 1216
猫巷女王i
猫巷女王i 2020-12-20 21:23

I am trying to validate a URL with this method:

Code:

- (BOOL) validateUrl: (NSString *) candidate {

    NSString *urlRegEx=
    @\"((https?|ftp|gop         


        
4条回答
  •  感情败类
    2020-12-20 21:29

    What about using the following:

    NSURL * url = [NSURL URLWithString:@"http://www.google.com"];

    BOOL isValid = [UIApplication.sharedApplication canOpenURL:url];

    note: best practice is to use regex

提交回复
热议问题