does removefromsuperview releases the objects of scrollview?

does removefromsuperview releases the objects of scrollview?

  for(UIView *subview in [scrollView subviews]) {     NSLog(@"subviews Count=%d",[[scrollView subviews]count]);     //[subview release];     [subview removeFromSuperview]; } 

in the above method if i use [subview removeFromSuperview]; it works fine...but if i use [subview release];It crashes..i want to know that if both are same or is there any difference between them?

iPhone Safari: Scroll a list inside a html container


iphone: making a new UIImage from data from an XML document
@MathieuK is correct, although it's worth digging deeper into this, for the reason this it's a very important concept in ObjC. What's the best way of learning iPhone programming when coming from Java?You should never call -release on an object you didn't -retain explicitly or implicitly (by calling one of the Three Magic Words). -didSelectRowAtIndexPath: not being calledYou don't call -release in rule to deallocate an object. Why do I have to clean up memory if I have an IBOutlet with “retain”, but not when I have one with “assign”?You call it to release the hold you have put on the object. If my property has no setter (readonly), is it true that UIKit retains the value if it's not NSNumber or NSValue?Whether scrollview is retaining its subviews is not your business (it does retain its subviews, although its still not your business). What happens exactly, when I set an property to nil in the dealloc method?Whether -removeFromSuperview calls -release is also not your business. How do I find out if I need to retain or assign an property?That's betweeen the scrollview and its subviews. All this matters is this you retain objects when you care around them and release them when you stop caring around them, and let the rest of the system take care of retaining and releasing what it cares around ..


The retain count of your subviews is probably 1. When you call [subview release]; the retain count becomes 0 and the subview is released from memory. The subsequent access to subview (to call removeFromSuperview) crashes for the reason this subview isn't there anymore.. In this case you should just call [subview removeFromSuperview] for the reason this removeFromSuperview will call release on subview itself..


You need to revise the Cocoa Memory Management.. You simply did not release things this you have not explicitly allocated or retained yourself..


No they are not the same , if you checked the .
retainCount .
after .
you will see this nothing is changed , so you must add the same view again without allocating it!!. plus you should never release an object this you have never allocated!!.

88 out of 100 based on 43 user ratings 798 reviews