And then there is
// Add the newly created contact to the address book
ABAddressBookAddRecord (addressBook, person, NULL);
The next step is to save the address book in order to better learn how to deal with the Error that will not cause crashes and prompts. It is recommended that you create an Error object to see the Error prompts given by the system
CFErrorRef error = NULL;
If (ABAddressBookSave (addressBook, & amp; error))
{
UIAlertView * Alert = [[UIAlertView Alloc] initWithTitle:@” prompt “Message :@” has successfully imported contacts into address book” delegate: Self cancelButtonTitle:@” confirm “otherButtonTitles:nil];
[alert show];
}
The else
{
NSLog (@ “% @”, the error).
UIAlertView * Alert = [[UIAlertView Alloc] initWithTitle: @@” prompt “message:@” import failed” delegate:self cancelButtonTitle:@” confirm “otherButtonTitles:nil];
[alert show];
}
The error is “error Domain=ABAddressBookErrorDomain Code=1 “The operation couldn’t be completed. (ABAddressBookErrorDomain error 1.)”
This error basically means that the operation is not complete, which does nothing to me, but at least it tells us one thing, that there is nothing wrong with the code we write. If there’s nothing wrong with the code, why did it fail to save the contact to the address book?The only answer seems to be that the system won’t allow you to access the address book
Solution: First in the phone’s privacy Settings, address book privacy to see if the permissions are turned on.
It then gives a code to request application access to the address book before importing.
if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) {
ABAddressBookRequestAccessWithCompletion (addressBook, ^ (bool granted, CFErrorRef error) {
The first time, a prompt will pop up telling the user whether to allow the application to access the address book
});
}
Else if (ABAddressBookGetAuthorizationStatus () = = kABAuthorizationStatusAuthorized) {
Description accessible
}
The else {
The user may have turned off access to the communication.
}
Well, the problem with the address book not being able to hold data has finally been solved.
Read More:
- Error: enoent: no such file or directory, stat ‘/ usr / local / var / www / / book/gitbook/git
- Error: enoent: no such file or directory, stat ‘/ usr / local / var / www / /_ book/gitbook/git
- Common problems of Aidl cross process communication
- Websocket code 200 error
- Developing in Android java.net.SocketException : socket failed: eacces (permission denied) reported an error
- IIS + Django project reported an error. The fastcgi process exited unexpectedly
- ARP – s in win7 (ARP binding under win7)
- Uncaught typeerror: cannot set property ‘of null error resolution
- To solve the problem of C # calling excel interface error, prompt: the COM object of Microsoft. Office. Interop. Excel. Applicationclass is forcibly converted to the interface type “Microsoft. Offi”
- Springboot project start swagger prompt error err_ CONNECTION_ Refused solution
- This application has no explicit mapping for /error, so you are seeing this as a fallback (How to Fix)
- Big hole in using OpenGL on Mac OS
- Breaking Baidu’s secret of making money by reading
- HTTP load failed, 0/0 bytes (error code: -1003 [10:-72000])
- java.lang.AbstractMethodError: Receiver class com.alibaba.cloud.sentinel.feign.SentinelContractHolde
- MySQL data import error 1227, acess denied
- Solution to Starting Fault of routing and remote access service (16389 (0x4005))
- Solve the problem of Failed to load resource: net::ERR_CONNECTION_REFUSED
- Navicat VMware failed to connect to the database. Possible causes of error 2003
- HTTP error code compact version