Why do I get this linker error in iOS when I create location lines in longitude and latitude?

I have longitude and latitude from the location manager, now I'm trying to change the geocode to convert this information to address strings. I found the code below that is supposed to do this, but I am getting a linker error. I think it means I'm missing some kind of structure or something like that. I could not find the answer. Can anyone help?

Error:

Apple Mach-O Linker Error "_KABPersonAddressZIPKey", referenced from: 

etc. for each of the lines I'm trying to generate.

  CLGeocoder *geocoder = [[CLGeocoder alloc] init]; CLLocation *newLocation = [[CLLocation alloc]initWithLatitude:latitude longitude:longitude]; [geocoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray *placemarks, NSError *error) { if (error) { NSLog(@"Geocode failed with error: %@", error); return; } if (placemarks && placemarks.count > 0) { CLPlacemark *placemark = placemarks[0]; NSDictionary *addressDictionary = placemark.addressDictionary; NSString *address = [addressDictionary objectForKey:(NSString *)kABPersonAddressStreetKey]; NSString *city = [addressDictionary objectForKey:(NSString *)kABPersonAddressCityKey]; NSString *state = [addressDictionary objectForKey:(NSString *)kABPersonAddressStateKey]; NSString *zip = [addressDictionary objectForKey:(NSString *)kABPersonAddressZIPKey]; NSLog(@"%@ %@ %@ %@", address,city, state, zip); } } ]; 
+4
source share
3 answers

Add the following structure to your project and import it.

 AddressBook.framework AddressBookUI.framework 

enter image description here

+6
source

Have a look at kABPersonAddressStreetKey in the documentation:

http://developer.apple.com/library/ios/#documentation/AddressBook/Reference/ABPersonRef_iPhoneOS/Reference/reference.html

At the top of the page, it is at the top of the AddressBook structure. Therefore, you need to refer to this.

+7
source

The code you entered uses some of the constants in the AddressBook structure. You need to add the AddressBook infrastructure to the target project.

+2
source

Source: https://habr.com/ru/post/1442671/


All Articles