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

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -