.h ---------------
#import <Cocoa/Cocoa.h> @interface NSString (Utilities) - (BOOL) isURL; @end

.m -----------------
#import "NSString-Utilities.h" @implementation NSString (Utilities) - (BOOL) isURL { if ( [self hasPrefix:@"http://"] ) return YES; else return NO; } @end


usese -----------------

NSString* string1 = @"http://pixar.com/"; NSString* string2 = @"Pixar"; if ( [string1 isURL] ) NSLog (@"string1 is a URL"); if ( [string2 isURL] ) NSLog (@"string2 is a URL");

'Object-C' 카테고리의 다른 글

NSLog  (0) 2010.12.15
adHoc  (0) 2010.12.13
init  (0) 2010.12.03
textbox 글자수에 따른 height 가져오기  (0) 2010.11.26
HIG  (0) 2010.11.07

+ Recent posts