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
Post a Comment