Skip to content

Commit

Permalink
Added readme, license and podspec
Browse files Browse the repository at this point in the history
  • Loading branch information
belkevich committed Jan 13, 2014
1 parent 1dff44b commit 127eaec
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 2 deletions.
14 changes: 14 additions & 0 deletions APAddressBook.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Pod::Spec.new do |s|
s.name = "APAddressBook"
s.version = "0.0.1"
s.summary = "Easy access to iOS address book"
s.homepage = "https://github.com/Alterplay/APAddressBook"
s.license = { :type => 'MIT', :file => 'LICENSE.txt' }
s.author = { "Alexey Belkevich" => "[email protected]" }
s.source = { :git => "https://github.com/Alterplay/APAddressBook.git",
:tag => s.version.to_s }
s.source_files = 'Classes/**/*.{h,m}'
s.ios.deployment_target = "5.0"
s.requires_arc = true
s.frameworks = 'AddressBook'
end
2 changes: 1 addition & 1 deletion Classes/APTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ typedef enum
APContactFieldEmails = 1 << 4,
APContactFieldPhoto = 1 << 5,
APContactFieldDefault = APContactFieldFirstName | APContactFieldLastName |
APContactFieldPhones,
APContactFieldPhones,
APContactFieldAll = APContactFieldDefault | APContactFieldCompany |
APContactFieldEmails | APContactFieldPhoto
} APContactField;
Expand Down
7 changes: 7 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright (c) 2013 Alterplay

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
105 changes: 104 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,105 @@
APAddressBook
=============
============

#### About
APAddressBook is a wrapper on [AddressBook.framework](https://developer.apple.com/library/ios/documentation/AddressBook/Reference/AddressBook_iPhoneOS_Framework/_index.html)

---

#### Features
* Load contacts from iOS address book asynchronously
* Decide what contact data fields you need to load (for example, only first name and phone number)
* Filter contacts to get only necessary records (for example, you need only contacts with email)
* Sort contacts with array of any [NSSortDescriptor](https://developer.apple.com/library/mac/documentation/cocoa/reference/foundation/classes/NSSortDescriptor_Class/Reference/Reference.html)

#### Installation
Add `APAddressBook` pod to Podfile

---

#### Using

###### Load contacts
```objective-c
APAddressBook *addressBook = [[APAddressBook alloc] init];
// don't forget to show some activity
[addressBook loadContacts:^(NSArray *contacts, NSError *error)
{
// hide activity
if (!error)
{
// do something with contacts array
}
else
{
// show error
}
}];
```
---
###### Select contact fields bit-mask
Available fields:
* APContactFieldFirstName - *contact first name*
* APContactFieldLastName - *contact last name*
* APContactFieldCompany - *contact company (organisation)*
* APContactFieldPhones - *contact phones array*
* APContactFieldEmails - *contact emails array*
* APContactFieldPhoto - *contact photo*
* APContactFieldDefault - *contact first name, last name and phones array*
* APContactFieldAll - *all contact fields described above*
Example of loading contact with first name and photo:
```objective-c
APAddressBook *addressBook = [[APAddressBook alloc] init];
addressBook.fieldsMask = APContactFieldFirstName | APContactFieldPhoto;
```

---

###### Filter contacts
The most common use of this option is to filter contacts without phone number
Example:
```objective-c
addressBook.filterBlock = ^BOOL(APContact *contact)
{
return contact.phones.count > 0;
};
```

---

###### Sort contacts
APAddressBook returns unsorted contacts. So, most of users would like to sort contacts by first name and last name.
```objective-c
addressBook.sortDescriptors = @[
[NSSortDescriptor sortDescriptorWithKey:@"firstName" ascending:YES],
[NSSortDescriptor sortDescriptorWithKey:@"lastName" ascending:YES]
];
```

###### Check address book access
```objective-c
switch([APAddressBook access])
{
case APAddressBookAccessUnknown:
// Application didn't request address book access yet
break;

case APAddressBookAccessGranted:
// Access granted
break;

case APAddressBookAccessDenied:
// Access denied or restricted by privacy settings
break;
}
```

---

#### Contacts

[Check out](https://github.com/Alterplay) all Alterplay's GitHub projects.
[Email us](mailto:[email protected]?subject=From%20GitHub%20APAddressBook) with other ideas and projects.

0 comments on commit 127eaec

Please sign in to comment.