Tuesday, 15 March 2011

ios - How to use NSArray predicate in objective c? -



ios - How to use NSArray predicate in objective c? -

i having nsarray objects.

example:

nsarray *objects = [nsarray arraywithobjects:@"one",@"two",@"three",@"one",@"two",@"four",@"five",@"one",nil];

in above array , object @"one" occurred 3 times.if predicate or filter object. has display 1 time remaining objects in new array.

expected output:

(one , two, three, two, four, five).

probably easiest way utilize nsset not nsarray.

nsarray *objects = @[@"one",@"two",@"three",@"one",@"two",@"four",@"five",@"one"]; nsset *uniqueobjectset = [nsset setwitharray:objects];

uniqueobjectset contain each unique value once.

you can go array...

nsarray *uniqueobjectarray = [uniqueobjectset allobjects];

ios objective-c xcode5 nsarray

No comments:

Post a Comment