• 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
dealloc event
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

dealloc event


  • Subject: dealloc event
  • From: "Theodore H. Smith" <email@hidden>
  • Date: Fri, 20 May 2005 13:30:29 +0100

Sorry this is a very basic question, but I didn't see it answered in the Cocoa docs.

If I have some object defined with object fields, must I release them on my object's dealloc event, or does this happen automatically?

@interface MyDocument : NSDocument
{
	NSData* MyData;
}
- (void) dealloc;
@end

Let's say that I've previously retained MyData.

- (id)init {
	MyData = [[self GetSomeData] retain];
	...
}

So should I do this?

- (void) dealloc {
	[MyData release];
}

or this:

- (void) dealloc {
	;
}


In C++ you wouldn't have to release anything for objects in the struct, but I have a feeling I need to call release in the dealloc event in ObjC.




--
elfdata.com/plugin/ Industrial strength string processing, made easy.

"All things are logical. Putting free-will in the slot for premises in
a logical system, makes all of life both understandable, and free."

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: dealloc event
      • From: mmalcolm crawford <email@hidden>
    • Re: dealloc event
      • From: j o a r <email@hidden>
  • Prev by Date: NSMetadataQuery can not be synchronous ?
  • Next by Date: Length of a file
  • Previous by thread: NSNoSelectionMarker and friends
  • Next by thread: Re: dealloc event
  • Index(es):
    • Date
    • Thread