Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8270849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:42:07+00:00 2026-06-08T06:42:07+00:00

I am getting contact details and am having memory problems in my shouldContinueAfterSelectingPerson method.

  • 0

I am getting contact details and am having memory problems in my shouldContinueAfterSelectingPerson method. I followed a tutorial and did this weeks ago but now when I click Product -> Analyze I get ‘Potential leak of an object allocated on line’ on these 3 lines:

[lastName setText:(__bridge NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty)];

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];

[dateOfBirth setText:birthday];

When clicking on these errors I get (though only number 2 for the third line):

  1. Call to a function ‘ABRecordCopyValue’ returns a Core Foundation object with a + 1 retain count

  2. Object leaked: allocated object is not referenced later in this execution path and has a retain count of + 1

The full code is shown below:

- (BOOL)peoplePickerNavigationController: (ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person {

[firstName setText:(__bridge NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty)];

[lastName setText:(__bridge NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty)];

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MMMM d, yyyy"];
birthday = [dateFormatter stringFromDate:(__bridge NSDate *)ABRecordCopyValue(person, kABPersonBirthdayProperty)];
[dateOfBirth setText:birthday];

Is there a fix around this and how important is it that I do fix it? I have one other potential leak of an object in my code.

A final note: I am using ARC.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T06:42:08+00:00Added an answer on June 8, 2026 at 6:42 am

    You want this:

    [lastName setText:(__bridge_transfer NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty)];
    

    The reason you’re seeing the warning from the analyser is that ABRecordCopyValue returns a CFStringRef with +1 retain count. You’re then casting to an NSString* but saying to ARC not to take ownership of the object. That means it won’t automatically add in the release for you. So you need to tell ARC to take ownership during the cast into Objective-C object land which is done using __bridge_transfer.

    You could also have done:

    CFStringRef string = ABRecordCopyValue(person, kABPersonLastNameProperty);
    [lastName setText:(__bridge NSString *)string];
    CFRelease(string);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting contact details for a given phone number using the following code:
I have rows in a contact details database that look like this: contactID -
Some of our users are getting this exception sometimes (not for every contact): System.Runtime.InteropServices.COMException
I am working on this school project and I am having trouble getting my
Sorry, if this is a noobish question, but I'm just getting started with Rails
I am having problems getting Microsoft Charting: System.Web.DataVisualization.dll To work in the Medium Trust
via server API's i'm getting contact information using member of structure: char displayName[USERNAME_MAX_SIZE]; One
I am getting records from database as comma separated. I am getting contact titles
Getting red warning message that expected identifier for this statement CALayer = ImageView.layer; Using
Getting this out of the way; I don't frequently do much in php or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.