I have a string as 开发者_运维百科 http://www.google.co.uk/ig/images/weather/partly_cloudy.gif. I need to save only the partly_cloudy.gif .How do i select obly that part of string?
If you are sure that it represents a path then you can call the lastPathComponent
method on it.
Usage
NSString * link = @"http://www.google.co.uk/ig/images/weather/partly_cloudy.gif";
NSLog(@"%@", [link lastPathComponent]);
Use the NSString function componentsSeparatedByString
. For example, NSString *url = @"http://www.google.com/1/2/3/test.gif"; NSArray *components = [url componentsSeparatedByString:@"/"];
would give you an NSArray of all strings in between a '/' character.
NSString reference: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html
精彩评论