Jon
Jon

Reputation: 4732

Need to get string from NSArray

I have an NSArray that looks like this:

![enter image description here][1]

I need to create an NSArray that has the first URL from each of the 4 dictionaries in the array I posted. Then I will set these as a cell's text info with objectAtIndex:indexPath.row

Upvotes: 0

Views: 974

Answers (1)

user866214
user866214

Reputation:

Isn't it an array of arrays of arrays ? Run a simple loop to do it :

NSMutableArray *urls = [NSMutableArray array];
for(NSArray *a in theArray) {
    NSArray *nestedArray = [a objectAtIndex:0];
    // if you need the whole string
    //[urls addObject:[nestedArray objectAtIndex:0]];
    // if you just need the first part of the URL
    NSArray *components = [[nestedArray objectAtIndex:0]
                           componentsSeparatedByString:@"?"];
    [urls addObject:[components objectAtIndex:0]];
}
// you got them

Upvotes: 4

Related Questions