开发者

Split string items [closed]

开发者 https://www.devze.com 2023-03-26 02:18 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
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

精彩评论

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

关注公众号