0

My app is connecting to an external database and downloading JSON data. The Data is stored in an array of dictionaries with each one representing a user profile.

There is a key in every dictionary that displays if they are visible or invisible. The value of this key is either 1 or 0.

I want to pass only the "visible" profiles into a tableview. The visible profiles are represented by a 1 in the "active" key.

Basically I want to loop through the main dictionary array and create a new array of dictionaries that contains only dictionaries that have that key value.

anyone know the best way to do this?

Connor Pearson
  • 63,902
  • 28
  • 145
  • 142
DanR
  • 141
  • 2
  • 9

1 Answers1

1

Check out NSPredicate. There's an example here. Here's an answer which filters dictionaries in an array: Using NSPredicate to filter an NSArray based on NSDictionary keys.

Community
  • 1
  • 1
Simon
  • 1,746
  • 1
  • 13
  • 21