parse.com - How to remove duplicate data in the UIPickerView in Swift -



parse.com - How to remove duplicate data in the UIPickerView in Swift -

may know how remove duplicate info data passing parse database. select 1 column , pass column info picker view. i've seek find query.wherekey didn't have distinct function similar sql statement, should avoid info duplication?

as add together items 1 1 self.pickerstring array, verify if array contains or not new value before addobject new value array. example:

if !self.pickerstring.contains(object["intake"] as! string) { self.pickerstring.append(object["intake"] as! string) }

there no built-in function remove duplicate items in array in swift (correct me if i'm wrong). however, can add together new features array 'extension' keyword:

extension array { func distinct<t: equatable>() -> [t] { var newarray = [t]() item in self { if !contains(newarray, item as! t) { newarray.append(item as! t) } } homecoming newarray } }

usage:

let s = ["344","333","1","2","333"] var p = s.distinct() [string]

swift parse.com ios8 xcode6 uipickerview

Comments

Popular posts from this blog

Using Android Volley to post an array to PHP -

python - How to add an model instance to a django queryset? -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -