0

I was wondering if it is possible to create a address book or contacts app, like Apple's, that uses Core Data and an SQLite storage file.

The part I am not sure if it is possible, or how to do it is having multiple properties for phones. So a user could input five different phone numbers for the same contact.

The only way I could think of doing it is say... have one entity for the person... then another entity for phones with them having a relationship. So one person could have multiple phones but one phone could only have one person. But that didn't seem to like it would be a good way to do it... anyone have a suggestion?

4

1 回答 1

4

I don't see how you came to the conclusion that several entities are not a good way to do something like this. That's the only way to do it if you want flexibility. Adding three phone number attributes to your entity is definitely the wrong way.

I would use a simple data model like this:

enter image description here

Each record has a type (e.g. email, phone, fax, IM contact) a key (e.g. office, home, mobile, twitter, jabber) and a value (e.g. 55512345, foo@bar.com, @foobar).

Such a model offers the most flexibility and it's not very complicated to implement.
Though you need a couple of predicates to get phone numbers, emails etc.

于 2012-05-26T11:26:37.087 回答