• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: AB extensions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AB extensions


  • Subject: Re: AB extensions
  • From: Joseph Jones <email@hidden>
  • Date: Tue, 30 Sep 2003 20:52:30 -0700

Thanx to the keen eyesight of a couple of posters, I have been able to correct a few bugs in this code.

1) Memory leak when not releasing mutableCopy instances.
2) Properties may return as ABMultiValues instead of strings. In this case, we return the first value in the multi value prop.

Updated code can be obtained at : http://www.jtechsoftworks.com/samples/JTAddressBook.sit

Thanx all!

On Tuesday, September 30, 2003, at 08:15 PM, Shaun Wexler wrote:

On Sep 30, 2003, at 6:29 PM, Joseph Jones wrote:

Interesting. I thought convenience methods like mutableCopy gave you an already autoreleased object! I also thought that collections cleaned up their retained objects when they release. Is this not correct?

Nope.

Anything you +alloc, +allocWithZone:, -copy, -copyWithZone:, -mutableCopy, or -mutableCopyWithZone: returns a NEW object with a retain count of 1. Adding it to a collection which retains it bumps that to 2, and if you lose a reference to it, when the collection releases it (upon removal), it will leak. Any objects that are returned to you by calling methods should be autoreleased, and/or are owned by the receiver, so if you need to keep a reference to it yourself, you retain it and assign it to a pointer (id). You still don't own it, but if the actual owner (which created the object) releases it, whenever you release it, then it might be dealloc'ed.

Better revise your code ASAP... ;)
--
Shaun Wexler
MacFOH
http://www.macfoh.com



Thank you,
Joseph Jones
JTech Softworks, Inc. - http://www.jtechsoftworks.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: NSData encoding issues...
  • Next by Date: Re: how to stop NSString/NSData from interpreting backslash
  • Previous by thread: Rendezvous and Distributed Objects Help
  • Next by thread: Re: how to stop NSString/NSData from interpreting backslash
  • Index(es):
    • Date
    • Thread