Requesting Access to the Address Book – Swift Language – iOS 8

Request to Access Address Book
Request to Access Address Book

Here is simple steps to requesting access to the Address Book in Swift Language iOS 8

Import the framework of Address Book:

      import AddressBook

Create an object of Address Book:

      var addressBook: ABAddressBookRef?

Create a method for assigning the value to addressBook:

      func createAddressBook(){
          var error: Unmanaged<CFError>?
          addressBook = ABAddressBookCreateWithOptions(nil, &error).takeRetainedValue()

Post following code to requesting access:

      switch ABAddressBookGetAuthorizationStatus(){
      case .Authorized:
        println("Already authorized")
        /* Access the address book */
      case .Denied:
        println("Denied access to address book")

      case .NotDetermined:
        if let theBook: ABAddressBookRef = addressBook{
            {(granted: Bool, error: CFError!) in

              if granted{
                println("Access granted")
              } else {
                println("Access not granted")


      case .Restricted:
        println("Access restricted")

        println("Other Problem")

Happy Coding 🙂