objective c - How to get objects from array of objects for given key -


i rows database array. , example have in these rows fields ´id´,´section´. possible id´s chosen section array without loops using operators? instance

1 2 b 2 3 4 b

and section 'a' i'd [1,2,3]

if database array of tuples can this:

let database: [(int, string)] = [(1, "a"), (2, "b"), (2, "a"), (3, "a"), (4, "b")]  let anumbers = database.filter{ $0.1 == "a" }.map{ $0.0 } 

or swift 2:

let anumbers = database.flatmap{ $0.1 == "a" ? $0.0 : nil } 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -