iOS Swift: Find index for CKRecord in array -


i'm trying use find function index of ckrecord in array. i'm running problem don't understand.

i have 2 arrays: notes , allnotes. notes subset of allnotes. have item notes , i'm trying find index within allnotes. can see output exists in both arrays, being found in notes array.

func removenoteatindexpath(indexpath: nsindexpath) {     let note = tableviewcontroller.notes[indexpath.row]      if let index = find(allnotes, note) {         println("found in allnotes")     } else {         println("not found in allnotes")     }      if let index = find(tableviewcontroller.notes, note) {         println("found in notes")     } else {         println("not found in notes")     }      println(tableviewcontroller.notes[0])     println(allnotes[0]) } 

console output

not found in allnotes found in notes <ckrecord: 0x7fb49ad37120; recordtype=note, recordid=e6bd60a1-ab15-4952-84a3-81bdb4dfc961:(_defaultzone:__defaultowner__), recordchangetag=i8nh54t3, values={     text = "my note"; }> <ckrecord: 0x7fb49ac31f60; recordtype=note, recordid=e6bd60a1-ab15-4952-84a3-81bdb4dfc961:(_defaultzone:__defaultowner__), recordchangetag=i8nh54t3, values={     text = "my note"; }> 

you need adapt equatable protocol ckrecord below.

extension ckrecord: equatable {} public func ==( lhs: ckrecord, rhs: ckrecord ) -> bool {     return lhs.recordid.recordname == rhs.recordid.recordname } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -