ios - Multipeer Connectivity send and receive NSManagedObject -


i'm looking send , receive nsmanagedobject through multipeer connectivity framework.

class myobject: nsmanagedobject {  @nsmanaged var name: string @nsmanaged var children: nsset 

}

i've managed send strings , dictionaries, need send nsmanagedobject nsset. possible?

here's i've tried:

let data = nskeyedarchiver.archiveddatawithrootobject(nsmanagedobject)      if session.connectedpeers.count > 0 {          var error: nserror?         if !session.senddata(data,topeers: session.connectedpeers, withmode: .reliable, error: &error){              println("send error:")             println(error)          }      } else {          println("no peers connected!")      }  func session(session: mcsession!, didreceivedata data: nsdata!, frompeer peerid: mcpeerid!) {      nslog("%@", "didreceivedata: \(data.length) bytes")      let nsmanagedobject = nskeyedunarchiver.unarchiveobjectwithdata(data) as! myobject  } 

the problem sending nsmanagedobject different device has been persisted core data on source device, cannot deserialized , inserted persistent store of target.

i suggest serializing objects nsdictionary, sending data, , implementing find-or-create correctly insert new managed objects on target device.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -