Hi everyone,
I can't seem to figure out how to get a substring from an array element to a different string:
I have the following NSArray:
"image1.png|Description for image"
"image2.png|Description for image"
"image3.png|Description for image"
I already have the image name in a for loop but can't get the descpription where it matches the image name in the array.
Code:
NSString *imageDesc = nil;
NSString *positionsPath = [[NSBundle mainBundle] pathForResource:@"position_descriptions" ofType:@"txt" inDirectory:@"/"];
NSArray *positionsDesc = [[NSString stringWithContentsOfFile:positionsPath encoding:NSUTF8StringEncoding error:nil] componentsSeparatedByString:@"\n"];
...
...
...
UIImage *image = [UIImage imageNamed:imageName];
imageView = [[UIImageView alloc] initWithImage:image];
I'd like to get the corresponding imageDesc from NSArray where it's equal to the imageName.
Any help would greatly be appreciated.
Thanks!