Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Quick and basic retain/release/pointers question



SomeCusomView *aView = [[SomeCustomView alloc]
initWithFrame:aRect];
[anotherView addSubview:aView];
[aView release];

//...

[aView doThisOrThat];

Your assumptions are correct. Calling [anObject release] the object only actually releases when the retain count is 0. It is not moved in memory.
The fact that the runtime complains about a selector not recognized indicates that the object still 'lives' (otherwise you'd probably get a SIGBUS or something).
For debugging purposes, use NSLog(@"%d", [anObject retainCount]); to find out the current retain count of your object.
Clever use of autorelease and nested autorelease pools can save you some headache. Read Apple's documentation.


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Quick and basic retain/release/pointers question (From: Keith Blount <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.