• 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: Memory Management and NSView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory Management and NSView


  • Subject: Re: Memory Management and NSView
  • From: mmalc crawford <email@hidden>
  • Date: Thu, 9 Aug 2007 14:05:18 -0700


On Aug 9, 2007, at 1:58 PM, Chris Poliquin wrote:

I have a custom view with an attached class. I declare a MutableArray in the header file and alloc and init it in initWithFrame.

Then is drawRect I access a member of the array. The first time drawRect is called this works fine, but the second time the program crashes. If I retain the array in the top of drawRect everything works fine, but the retain count just increases every time drawRect is called and this seems wrong. If I retain the array at the top and release it at the bottom the program goes back to crashing again when drawRect is called.

Please post the relevant code.

If you are *just* alloc-ing the array in initWithFrame: (and you're not releasing it), you should be fine (assuming you remember to release it in dealloc). [Better still (as a beginner) would be to use accessor methods (see <http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmPractical.html >).]

mmalc

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Memory Management and NSView (From: Chris Poliquin <email@hidden>)

  • Prev by Date: Re: Integrating Unix scripting in Cocoa app
  • Next by Date: Re: Integrating Unix scripting in Cocoa app
  • Previous by thread: Re: Memory Management and NSView
  • Next by thread: Re: [FIXED] calling scrollPoint: on table view from separate thread locks up app
  • Index(es):
    • Date
    • Thread