프로그래밍/Objective C

APPLE :: SelectString (문장 잘라내기)

청년코더 2010. 11. 10. 03:25
#SelectString

맥에서 포팅하는 재미란...=_=

대략 아래 코드 사이에 있는 문장을 파싱해왔다고 가정하에.. image URL만 뽑아내야 할때 사용, 출처는 그분(?)!

NSString *willParseData = @"<img src='/Shop/img/42/1078/pbbr045_225.jpg' border=0 width=225 height=225 />";

NSArray *separatedString = [willParseData componentsSeparatedByString:@"'"];


NSMutableString *imsiURL = [NSMutableStringstringWithString:@"http://www.schoolmusic.co.kr"];

[imsiURL appendString:[separatedString objectAtIndex:1]];


NSURL *imageURL      = [NSURLURLWithString:imsiURL];

NSData *imagefromURL = [NSDatadataWithContentsOfURL:imageURL];

UIImage *modelImage  = [[UIImagealloc] initWithData:imagefromURL];



완성된 이미지 URL = http://www.schoolmusic.co.kr/Shop/img/42/1078/pbbr045_225.jpg