在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
NSStringUtilities.h: #import <Foundation/Foundation.h> @interface NSString(Utilities) -(BOOL) isURL; @end NSStringUtilities.m #import "NSStringUtilities.h" @implementation NSString(Utilities) -(BOOL) isURL { if ([self hasPrefix:@"http://"]) { return YES; }else{ return NO; } } @end main.m: #import <Foundation/Foundation.h> #import "NSStringUtilities.h" int main(void) { @autoreleasepool { NSString* string1=@"http://www.google.com"; NSString* string2=@"Pixar"; if ([string1 isURL]) { NSLog(@"string is a url"); } if ([string2 isURL]) { NSLog(@"string2 is a url"); } } } console log: 2013-09-20 12:19:54.708 Obj-c[286:303] string is a url |
请发表评论