-1

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

0

1 Answer 1

4

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
Sign up to request clarification or add additional context in comments.

2 Comments

I tried this but this is what it logs out to :box.net/shared/static/5e9e0spgb26xzv2cokcu.png. This log has less brackets than the initial one so we got rid of one array, but I still need just an array for the first URL of each group;
Thanks, that worked. One last thing, can you update that last code so it also takes these lines into affect? Thanks! NSArray *components = [urlString componentsSeparatedByString:@"?"]; NSString *newString = [components objectAtIndex:0];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.