开发者

Split string items [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜