retaincount

Why shouldn't I release when assigning to a retain property?

This question is related to this one, but simpler. [I think I may be close to the end of these dumb questions and can get down to serious business :)]. I have a retain property and set to it like this: UINavigationController *thing = [[UINavigationController alloc] initWithRootViewController:one]; // thing's retain count is one nav...

Obj-C Memory Management Setter Method

I am new to objective-c and ive downloaded the code from here http://apress.com/resource/bookfile/4175 and ran the Chapter 10, 10.01 CarPartsInit xcode project file. One thing i am not clear about is that, does the memory management of a setter method - (void) setEngine: (Engine *) newEngine { [newEngine retain] [engine releas...

Should I release self.view?

Hi everyone, I have a question regarding to self.view in a UIViewController. First, in my app, everything is created programmatically. And normally I create self.view in the loadView method: self.view = [[UIView alloc]initWithFrame:SCREEN_FRAME]autorelease]; // SCREEN_FRAME is a constant At this moment, the retain count of self.view ...

view based application - viewcontroller retainCount after [window addSubview:viewController.view];

Hi, i have an view based application and when i checked if the dealloc method was workin, i saw that doesnt...debug and debug, then using retainCount, i discover that my viewcontroller retaincount gets crazy on the program start...its easy to reproduce.... just start a new view based application template, and in the didFinishLaunchingWi...

NSString and retainCount question

I have a NSString declared in the interface part: @property (nonatomic, retain) NSString *filePath; In viewDidLoad I give this a value and when I am trying to call it from one of my custom methods it works for the first time but on the second it crushes. In my opinion filePath was autoreleased during the first call. I tried a diff...

Objective C: @property(retain) doesn't call retain?

I was trying to track a strage memory allocation bug so I overrode the retain and release methods of my class. I noticed that when assigning an instance of this class to a property of another, the retain count of the object increased, but my redefined retain was never called. How can this be possible? Are (retain) properties retaining t...

IBOutlet UIWebView retainCount

Hi guys, I have a View Controller in which I have UIwebView created in IB. IBOutlet UIWebView *webView; @property (nonatomic, retain) IBOutlet UIWebView *webView; @synthesize webView; this webView has retainCount = 2 in viewDidLoad. Why? Thanks ...

iPhone - Retain Count - Retain count goes up for no apparent reason

Hello. Quick question, hopefully I am just missing something simple. Ok I have one class that holds a pointer to another; MainMenuClass and NormalGameClass. Inside of the MainMenuClass I do the following. m_NormalGame = [[NormalGameMode alloc] initWithNibName:@"NormalGameMode" bundle:[NSBundle mainBundle]]; m_NormalGame.delegate = sel...

How many times do I release an allocated or retained object?

Hi, I am making an iPhone game. I want to release all the object that have been allocated or retained. In the dealloc function I am releasing all such objects but then realized sometimes i end up releasing objects when they have not been allocated yet. So I figured I need to check if its retainCount is greater than zero or not before i ...

Methods That Call Methods: Basics of Autorelease?

Just when I thought I've understood this topic completely, I'm back to basics. I have a method that instantiates an autoreleased object, using (for example) stringWithFormat: return [NSString stringWithFormat:@"what"]; Then I call this method from another method, and another method, each time returning this autoreleased NSString and ...

Releasing object due to retain count

Hi all, I have an issue with releasing a view too many times. Although simple in theory because im moving uiview to uiview, which is a subclass of uiview and being animated and so on its not something that I can easily fix. It only crashes 10% and only under certain conditions and only 30% of the time even under these conditions. So i...

objective-c release

Hi, I have this class in DNS.h @interface DNS : NSObject <NSXMLParserDelegate, NSNetServiceDelegate> { NSMutableArray *servsPublished; } @property(nonatomic, retain) NSMutableArray *servsPublished; Then in the implementation file DNS.m there's a method where I release it and I get the exec bad access memory error. This is metho...

Adding @Property UISwitch to TableView Causes RetainCount Problems

I am doing this with UISwitchs and UITextFields... I have declared the UISwitch as Property in the header file, because I want to access its value in several different methods within my class. I am adding the UISwitch to one of my TableViewCells, using the following code: - (UITableViewCell *)tableView:(UITableView *)tableView cellFo...

Retain count in objective C return -1

I'm new to objective C, I have a NSMutableArray with 3 objects in it, then I try to print the retainCount of the array. Why the final retainCount return -1? Thanks NSLog(@"myArray has retain count of %d", [myArray retainCount]); [myArray release]; NSLog(@"myArray has retain count of %d", [myArray retainCount]); Result from console...

calling 'subviews' method on a cell's contentView increases retain count.

Hi, I don't know what is going on here but I have the following code in my init method: NSLog(@"retain count in init before alloc: %d", [game1CustomEntityInfoControl retainCount]); game1CustomEntityInfoControl = [[CustomEntityInfoControl alloc] initWithFrame:CGRectZero]; NSLog(@"retain count in init after alloc: %d", [game1CustomEnti...

retaincount of ViewController +4 when pushed by NavigationController

I was wondering why the retainCount of a viewController is raised by 4 when pushed onto the stack of a Navigationcontroller e.g. from a tableView. What dependencies are created? ...