URL Validation (Objective-C)

前端 未结 4 1217
猫巷女王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:39

    You can use + (id)URLWithString:(NSString *)URLString method of NSURL, which returns nil if the string is malformed.

    Use if (URL && URL.scheme && URL.host) for checking URL.

提交回复
热议问题