Fahim Parkar
Fahim Parkar

Reputation: 31627

how to get NSMutableArray From NSMutableArray

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?

Upvotes: 1

Views: 180

Answers (1)

Wain
Wain

Reputation: 119021

You can use KVC to get the array:

[[array valueForKey:@"FileURL"] mutableCopy];

Upvotes: 6

Related Questions