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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:42:30+00:00 2026-06-01T14:42:30+00:00

Here is my code to get Notes from AddressBook. +(NSString*)getNote:(ABRecordRef)record { return ABRecordCopyValue(record, kABPersonNoteProperty);

  • 0

Here is my code to get Notes from AddressBook.

 +(NSString*)getNote:(ABRecordRef)record {

  return ABRecordCopyValue(record, kABPersonNoteProperty);
}

But in above implementation I have memory leak. So to remove memory leak I wrote following code

    +(NSString*)getNote:(ABRecordRef)record {

    NSString *tempNotes = (NSString*)ABRecordCopyValue(record, kABPersonNoteProperty);
    NSString *notes = [NSString stringWithString:tempNotes];
    [tempNotes release];
    return notes;

}

If I write above code my app crashes. Whats going wrong? Thanks.

UPDATE: I call this method as follows :

notes = [AddreesBook getNote:record];

where notes is my ivar & I am releasing it in dealloc method.

  • 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-01T14:42:32+00:00Added an answer on June 1, 2026 at 2:42 pm

    Your first implementation violates the ownership rule:

    Memory Management Rules

    Which is to say, the API call you’re using contains “Copy”, but you’re treating it like an autoreleased object.

    Given that you’re returning an autoreleased object in your revised implementation, I suspect you’re not retaining your returned note string. You’ll be able to tell for sure if this is the case if when running under a debugger your app crashes in NSPopAutoreleasePool().

    A simple test would be to send -retain to the note object you get back and see if the crash goes away:

    NSString    *note = [ MyAddressBook getNote: abRecord ];
    
    [ note retain ];
    /* ... use note ... */
    
    /* we retained the object, we must also release it when done with it. */
    [ note release ];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is my code:(get file line num and word count) import System.IO import Data.Maybe
Here is my jQuery code: $.get('/Home/GetList', function(data) { debugger; $('#myMultiSelect').val(data); }); Here is my
I am trying to get the code found here: http://snipplr.com/view/26643/mbprogresshud-with-an-asynchronous-nsurlconnection-call/ to work in my
I cannot get this to work, here is code that I found in another
I am trying to get an HTML-based recursive directory listing based on code here:
Here is some code I could not get to format properly in markdown, this
Here is the code, any ideas why I get this error? private SQLiteDataAdapter DA_Webfiles;
Here's the code: mysql_query(DELETE . $_GET['id'] . FROM forum_favorites WHERE thread_id=' . $_GET['id'] .
Here is the code: $('#sousmenu a').click (function (){ startSlideshow(<?php echo json_encode(glob(photos- .$_GET[folder]. /*.jpg));?>); return
I have Java code which queries calendar entries from a Lotus Notes Domino server

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.