Alterplay / APAddressBook

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

APContact should be copy-able #139

Open vivekReddyBlackBuck opened 7 years ago

vivekReddyBlackBuck commented 7 years ago

user has 3 phone numbers , want to show them as rows in a table , if would be able to copy the APPerson contact , then it would be easy

belkevich commented 7 years ago

Sorry, I don't understand what exactly you can't copy?

vivekReddyBlackBuck commented 7 years ago

How do I create a copy of APContact object? If I assign Apcontact object to some variable , then I have a reference but I want a copy so that I can modify one of them and have 2 objects

vivekReddyBlackBuck commented 7 years ago

I think we need to implement copywithzone method , which is not there currently or is there any other method to make a copy and assign it to another variable

belkevich commented 7 years ago

Sorry, for delay. 1) Most of APAddressBook users expect that copy doesn't create so called 'deep copy'. But you can create the category for APContact class with your own copy/copyWithZone: method implementation and use it in your project. 2) You can create something like ContactsTableViewModel class that will store copies of APContact fields in format (for phones numbers?) that you exactly need. I think it's a best approach to avoid mutating original object