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 9073091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:20:03+00:00 2026-06-16T18:20:03+00:00

I have a class that accesses the address book, if I have the following

  • 0

I have a class that accesses the address book, if I have the following code then I get warnings from the analyzer, one is for a leak in the init method and another is saying the class doesn’t own the object when its releasing it in the dealloc.

I presume the 2nd warning is due to declaring the address book ref as assign? But its not possible to make it strong as this generates a compilation warning.
What is the correct way of dealing with the address book as a property?

@property (assign, nonatomic)   ABAddressBookRef                addressBook;

..
- (id) init
{
    self = [super init];
    if (self)
    {
        if (ABAddressBookCreateWithOptions)
        {
            // iOS 6 onwards
            self.addressBook = ABAddressBookCreateWithOptions(NULL, NULL);
        }
        else
        {
            // < iOS 6
            self.addressBook = ABAddressBookCreate();
        }
    }
    return self;
}


- (void) dealloc
{
    if (self.addressBook)
    {
        CFRelease(self.addressBook);
    }
}
  • 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-16T18:20:04+00:00Added an answer on June 16, 2026 at 6:20 pm

    It’s a false positive, you are correctly balancing the initial +1 of the retainCount with a the CFRelease call in the dealloc method.

    You can get rid of the warnings by using the ivar instead of the property to initialize and release the pointer.

    - (id) init {
        // ...
        _addressBook = ABAddressBookCreateWithOptions(NULL, NULL);
        //...
    }
    
    - (void)dealloc { 
        CFRelease(_addressBook); //assuming that _addressBook is your synthesized ivar
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that gets a movieClip and then using addChild adds it
I have public variable 'MessagePlaceholder' on MasterPage and a Class that accesses this property
Setup: I have a custom class I've created that handles data retrieved from a
I build a .NET Class Library project that accesses the mshtml.HTMLDocument when called (from
I have a Java class that accesses a MySQL database through JDBC that I
I have accessed a database in VB.NET using the following code: Public Class Form1
I have a windows application that accesses a file in a class library project.
I have a Singleton that is accessed in my class via a static property
I have class that extend FragmentActivity in it I add fragment to layout as
I have class that looks like this: class A { public: class variables_map vm

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.