0
NSString *string [email protected]"Highlight,[1234,1235,1236,1237],Issuer,[100,101,102,103]";
我需要存儲1234 1235 1236 1237在另一陣列的一個陣列分離的ID和存儲在兩個不同的陣列
100 101 102 103。
任何一個幫助我出
在此先感謝。
NSString *string [email protected]"Highlight,[1234,1235,1236,1237],Issuer,[100,101,102,103]";
我需要存儲1234 1235 1236 1237在另一陣列的一個陣列分離的ID和存儲在兩個不同的陣列
100 101 102 103。
任何一個幫助我出
在此先感謝。
你有一個類似的例子學習有關NSScanner
你的問題。
NSString *src = nil;
NSString *newsRSSFeed = @"<p><a href=\"http://us.rd.yahoo.com/dailynews/rss/us/*http://news.yahoo.com/s/ap/20110521/ap_on_re_us/us_michelle_obama_west_point\"><img src=\"http://d.yimg.com/a/p/ap/20110520/capt.53a8af4c675f421c8b7cba014c589d29-53a8af4c675f421c8b7cba014c589d29-0.jpg?x=130&y=97&q=85&sig=iOyBvkyg0rEKSK3hjlSsNA--\" align=\"left\" height=\"97\" width=\"130\" alt=\"First lady Michelle Obama, left, and Lt. Gen. David Huntoon, superintendent at the U.S. Military Academy, arrive in Washington Hall for a graduation banquet, Friday, May 20, 2011, in West Point, N.Y. (AP Photo/Mike Groll)\" border=\"0\" /></a>AP - First lady Michelle Obama urged more than 1,000 cadets Friday night on the brink of graduating to keep in mind the families of the soldiers they will lead.</p><br clear=\"all\"/>";
NSScanner *theScanner = [NSScanner scannerWithString:newsRSSFeed];
// find start of IMG tag
[theScanner scanUpToString:@"<img" intoString:nil];
if (![theScanner isAtEnd]) {
[theScanner scanUpToString:@"src" intoString:nil];
NSCharacterSet *charset = [NSCharacterSet characterSetWithCharactersInString:@"\"'"];
[theScanner scanUpToCharactersFromSet:charset intoString:nil];
[theScanner scanCharactersFromSet:charset intoString:nil];
[theScanner scanUpToCharactersFromSet:charset intoString:&src];
// src now contains the URL of the img
}
NSLog(@"%@",src);