swift - How to use the delegates with NSKeyedUnarchiver? -


i using nskeyedunarchiver unarchive object , use delegates (nskeyedunarchiverdelegate), delegates not called. archiving , unarchiving working fine, delegates (unarchiver & unarchiverdidfinish) not called. can help?

i have following implementation:

        class blobhandler: nsobject , nskeyedunarchiverdelegate{             func load() -> myobjectclass{                         let data:nsdata? = getblob();                     var mykeyedunarchiver:nskeyedunarchiver=nskeyedunarchiver(forreadingwithdata: data!);               mykeyedunarchiver.delegate = self;               let temp=mykeyedunarchiver.decodeobjectforkey("rootobject") // no delegates called                             if temp==nil {                                 blobsexists=false;                             }else{                                 objectreturn = temp! as! myobjectclass;                                 return objectreturn;                             }         }      func save1(myobject:myobjectclass){             let data = nsmutabledata()             var keyedarchiver:nskeyedarchiver=nskeyedarchiver(forwritingwithmutabledata: data);             keyedarchiver.encodeobject(maptheme, forkey: "rootobject");              let bytes = data.bytes;             let len=data.length;              saveblob(bytes);     } 

the following delegates, implemented in blobhandler, never called:

func unarchiver(unarchiver: nskeyedunarchiver, cannotdecodeobjectofclassname name: string, originalclasses classnames: [string]) -> anyclass? {     print("i in unarchiver !");     return nil; }  func unarchiverdidfinish(_ unarchiver: nskeyedunarchiver){     print("i in unarchiverdidfinish ! "); } 

i don't know was, working after clean , rebuild of project. notice different cases, builds not in sync sometimes. there code, in xcode not executed. sounds unbelievable, guess true. xcode 7.2


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -