Provide a class with a method which takes a ABAddressBook field
name, a person name, and a selector.
It finds all entries in the addressbook in which that field name
is populated and/or which match the name. ? ABAddressBook entries
for which the following is true are identified:
1) entries for which ? both the field name is populated, and the
name matches.
2) entries in which only the field is populated, but
the name does not match, or entries in which only the name matches.
By "name matches" we mean, either the first or last names match.
If both match for any entries, those entries ? are first in priority. In
particular, are listed first in any of the tableViews described below.
If the field is populated with more than one entry, then all entries
are considered.
## Deliverables
Provide a class with a method which takes a ABAddressBook field
name, a person name, and a selector.
It finds all entries in the addressbook in which that field name
is populated and/or which match the name. ? ABAddressBook entries
for which the following is true are identified:
1) entries for which ? both the field name is populated, and the
name matches.
2) entries in which only the field is populated, but
the name does not match, or entries in which only the name matches.
By "name matches" we mean, either the first or last names match.
If both match for any entries, those entries ? are first in priority. In
particular, are listed first in any of the tableViews described below.
If the field is populated with more than one entry, then all entries
are considered.
For concreteness, consider the case in which the field name in
question is "email" containing one or more email addresses. ? But
it could be phone number or another other pre-defined or custom
field name.
In the email case, this class is being used to allow the user to send
an email to a person who may be in the addressbook. So the selector
would be an email method. In the case of other fields, the selector
would have other functionality.
If the person
is not in the addressbook, and/or is in the addressbook but has no
email address, then the class will give the use the ability to add
the missing information so that when ? the class ? is invoked a second
time with the same information, then it will be able to call the selector,
in this case to send email to the person.
In the case 1) above (has email address and name match).
if one record matches, and only one email address, present UIAlert
allowing the user to confirm that they wish to send to that person
at that address. ? If "yes" then call the selector (to send the email
in this case).
If one name matches, but multiple email addresses, present a tableView
for the user to select the email address.
Similarly, if multiple records match with the name, then present the results
as a tableView for the user to select which one they mean. All matching records,
and all the entries in the matching email fields are shown in the tableview.
In case 2) ? above:
If there is more than one record, present the results in a tableView for
selection. ? In the tableView, show the name, and the email address
for each corresponding AddressBook entry. On the top bar, present
a button "add new AddressBook entry", which causes the AddressBook
UI for entering a new record to present modally.
If there is only one record for case 2), or a selection has been
made from the tableView , then present the addressbook modally with
that record, which allows the user to enter the missing email address
and/or name. ? When they are done, we are in case 1).
Note, again, that "email address" is used here only as an illustrative
example, the class should be able to handle any specified field
name, even a custom field name.