Alterplay / APAddressBook

Easy access to iOS address book
MIT License
1.38k stars 193 forks source link

-[APContact initWithCoder:]: unrecognized selector sent to instance (Swift 2) #112

Closed SergeyPetrovi4 closed 8 years ago

SergeyPetrovi4 commented 8 years ago

How to solve this?

I pack contacts array (APContact) to NSData

NSKeyedArchiver.archivedDataWithRootObject(contactsArray)

This worked, but when I tried unpack this data in another method I have ExeptionError

let addressBook = NSKeyedUnarchiver.unarchiveObjectWithData(data) as? [APContact]
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[APContact initWithCoder:]: unrecognized selector sent to instance
belkevich commented 8 years ago

You can create category APContact+NSCoder and implement initWithCoder: method there.

SergeyPetrovi4 commented 8 years ago

Big thanks ;)