1

I have NSMutableArray as below.

(
        {
        ClientId = "17";
        FileURL = "http://www.xxx.com/b0a89db3-482b-464e-81ae-78439527c702.jpg";
    },
        {
        ClientId = "56";
        FileURL = "http://www.xxx.com/f7633371-b726-4332-9b26-a98a2fed991d.jpg";
    }
)

What I want is NSMutableArray which will look similar to below.

NSMutableArray *image_array = 
    [NSMutableArray arrayWithObjects:
    @"http://www.xxx.com/b0a89db3-482b-464e-81ae-78439527c702.jpg", 
    @"http://www.xxx.com/f7633371-b726-4332-9b26-a98a2fed991d.jpg", 
    nil];

Any idea how to do that?


I tried with

NSArray *filtered = [feeds filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"(FileURL CONTAINS[cd] %@)", @"%http%"]];
NSLog(@"filter====%@", filtered);

but I am not getting anything. Data is blank.


Actually I have main array in below format.

(
        {
        ClientId = "17\n    ";
        FileURL = "http://www.xxx.com/b0a89db3-482b-464e-81ae-78439527c702.jpg\n\n";
    },
        {
        ClientId = "56\n    ";
        FileURL = "http://www.xxx.com/f7633371-b726-4332-9b26-a98a2fed991d.jpg\n\n";
    }
)

Any idea how to remove those \n and white spaces while creating new array?

2
  • Is it an array of dictionaries? Why not just iterate over them and grab the data? Commented Aug 26, 2013 at 18:56
  • There are methods in NSString like stringByTrimmingCharactersInSet: that'll let you remove the newlines. Commented Aug 26, 2013 at 19:01

1 Answer 1

6

You can use KVC to get the array:

[[array valueForKey:@"FileURL"] mutableCopy];
Sign up to request clarification or add additional context in comments.

2 Comments

I believe this gives back an NSArray, not an NSMutableArray.
@rmaddy, I can't test right now but I think you're right so I've edited.

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.