I have a string called aux which hold six url images, I want to split those images and display it in UIImage view the images are like
http://nssdc.gsfc.nasa.gov/planetar开发者_如何学JAVAy/image/cassini_titan_15.jpg
http://nssdc.gsfc.nasa.gov/planetary/image/cassini_titan_15.jpg
http://nssdc.gsfc.nasa.gov/planetary/image/cassini_titan_15.jpg
http://nssdc.gsfc.nasa.gov/planetary/image/cassini_titan_15.jpg
http://nssdc.gsfc.nasa.gov/planetary/image/cassini_titan_15.jpg
http://nssdc.gsfc.nasa.gov/planetary/image/cassini_titan_15.jpg
I want to split these images using if condition and display it in image-view.
If you read those lines from file where they one by one in separate rows, than you can try this:
NSString *urlsList = ... // your list in first post each url on it's line
NSArray *imagesURL = [urlsList componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
You simply need to determine what string is separating them. If you have that, you can just use the -[NSString componentsSeparatedByString:]
method. For example:
//This assumes they are separated with a comma
NSString *imageString = @"http://nssdc.gsfc.nasa.gov/planetary/image/cassini_titan_15.jpg,http://nssdc.gsfc.nasa.gov/planetary/image/cassini_titan_16.jpg";
NSArray *images = [imageString componentsSeparatedByString:@","];
// Now you have each image as an element on the images array
精彩评论