2

Is it possible to test some code relating the address book api in swifts playground? I don't know how to give xcode access to my address book.

This is my code:

let authorizationStatus = ABAddressBookGetAuthorizationStatus()

if (authorizationStatus == ABAuthorizationStatus.NotDetermined) {
    println("requesting access...")

    var emptyDictionary: CFDictionaryRef?
    var addressBook = !ABAddressBookCreateWithOptions(emptyDictionary, nil)
    ABAddressBookRequestAccessWithCompletion(addressBook,{success, error in
        if success {
            // do something 
        }
        else {
            println("unable to request access")
        }
    })
}
else if (authorizationStatus == ABAuthorizationStatus.Denied || authorizationStatus == ABAuthorizationStatus.Restricted) {
    println("access denied")
}
else if (authorizationStatus == ABAuthorizationStatus.Authorized) {
    println("access granted")
    // do something else
}

It prints me access denied -.-

dennis-tra
  • 1,309
  • 1
  • 14
  • 23
  • 1
    From my understanding the Swift Playground is really just a code interpreter like python. There isn't a file system or other properties the simulator has. So in short there is no Address Book to access from the playground. – John Riselvato Aug 18 '14 at 18:24

0 Answers0