retaincount

My retainCount is increasing?

眉间皱痕 提交于 2019-12-09 04:27:26
问题 am trying here to build rss reader , the problem that when user finish read artical and press back the dealloc don't called and i got retainCount 6 & some times 7 !! i have lots of customized panels when back button pressed the view is poped and no dealloc called ?! .h file : @interface ArticalViewController : UIViewController<UIWebViewDelegate,UIScrollViewDelegate,UIActionSheetDelegate,ArticalBottomPanelDelegate,ArticalContentFetcherDelegate> { UIWebView * description_;

Methods That Call Methods: Basics of Autorelease?

a 夏天 提交于 2019-12-08 12:26:57
问题 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 in each level of the hierarchy. The code works fine and the NSString instance is intact at each level of the hierarchy. I thought that since the instance is

RetainCount OK to use in this instance?

喜欢而已 提交于 2019-12-01 22:21:01
RetainCount == BAD retainCount is taboo, unreliable, unpredictable, and in general shouldn't be used. I don't use it anywhere in my code, but I have seen it in one class that I use in an interesting way. I have a class that runs a thread that runs indefinitely until the thread is cancelled. The catch is that the thread increases the retain count of the owner, in my case the class that instantiated it. So, even if I am done using that class, that instance is still going to hang around unless whoever is managing my class also has the smarts to know to shut down the thread. That is one solution,

Reference count is still 1 after [obj release], when it should be deallocated

邮差的信 提交于 2019-12-01 09:35:05
When I create an object and check its retain count, I get 1 as expected. When I release the object and then check the retain count again, it is still 1. Shouldn't the object be deallocated, and the retain count 0? NSMutableString *str=[[NSMutableString alloc] initWithString:@"hello"]; NSLog(@"reference count is %i",[str retainCount]); [str release]; NSLog(@"reference count is %i",[str retainCount]); I do see 0 for the retain count if I set str to nil first. Why is that? Don't use retainCount , it doesn't do what you expect in most cases. Your second NSLog is accessing deallocated memory as an

check retain count

折月煮酒 提交于 2019-11-30 09:08:20
问题 I am doing this : UIImageView *backgroundImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mainback.jpg"]]; [self.view addSubview:backgroundImage]; NSLog(@" retain count1 : %d " , [backgroundImage retainCount]); [self.view sendSubviewToBack:backgroundImage]; [backgroundImage release]; NSLog(@" retain count2 : %d " , [backgroundImage retainCount]); I got retain count1 : 2 retain count2 : 1 1 ) in dealoc function can i get message like : - (void)dealloc{ NSLog(@" retain count2 :

Weird behaviour with retainCount

跟風遠走 提交于 2019-11-29 15:33:09
When I am logging retain count with NSArray and NSString objects, I am having uneven behavior. See the code below, NSArray *aryTemp = [NSArray arrayWithObjects:@"One",nil]; NSLog(@"Retain Count :%d",[aryTemp retainCount]); NSArray *aryTemp2 = [[NSArray alloc] initWithObjects:@"One",nil]; NSLog(@"Retain Count :%d",[aryTemp2 retainCount]); NSString *strTemp = @"One"; NSLog(@"Retain Count :%d",[strTemp retainCount]); NSString *strTemp2 = [[NSString alloc] initWithString:@"One"]; NSLog(@"Retain Count :%d",[strTemp2 retainCount]); And this is the output I am getting 2011-03-01 19:19:32.410 Test

check retain count

守給你的承諾、 提交于 2019-11-29 12:40:24
I am doing this : UIImageView *backgroundImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mainback.jpg"]]; [self.view addSubview:backgroundImage]; NSLog(@" retain count1 : %d " , [backgroundImage retainCount]); [self.view sendSubviewToBack:backgroundImage]; [backgroundImage release]; NSLog(@" retain count2 : %d " , [backgroundImage retainCount]); I got retain count1 : 2 retain count2 : 1 1 ) in dealoc function can i get message like : - (void)dealloc{ NSLog(@" retain count2 : %d " , [backgroundImage retainCount]); [super dealloc]; } And 2) at last i got retain count 1 for

does addSubview increment retain count?

半腔热情 提交于 2019-11-29 07:17:02
I've tested it and it looks like it does. So my question is, does it ALWAYS increment the retain count. So everytime I do something like this: UIView *theView = [[[UIView alloc] initWithFrame:(CGRect)aFrame] autorelease]; [self.view addSubview:theView]; Am I actually leaking memory? I have a global property @property (nonatomic, retain) UILabel *ingredientsTextLabel; which I instantiate in viewDidLoad with this code: I just have the property named, theres no property for it in my header, so no getter and setter. In my viewDidLoad : ingredientsTextLabel = [[UILabel alloc] initWithFrame

Weird behaviour with retainCount

泄露秘密 提交于 2019-11-28 09:58:40
问题 When I am logging retain count with NSArray and NSString objects, I am having uneven behavior. See the code below, NSArray *aryTemp = [NSArray arrayWithObjects:@"One",nil]; NSLog(@"Retain Count :%d",[aryTemp retainCount]); NSArray *aryTemp2 = [[NSArray alloc] initWithObjects:@"One",nil]; NSLog(@"Retain Count :%d",[aryTemp2 retainCount]); NSString *strTemp = @"One"; NSLog(@"Retain Count :%d",[strTemp retainCount]); NSString *strTemp2 = [[NSString alloc] initWithString:@"One"]; NSLog(@"Retain

What is retainCount in Objective-C?

拟墨画扇 提交于 2019-11-27 23:41:28
问题 I have a UITableView as my first screen with a UINavigation controller. In my first screen I NSLog(@"Home Screen retain Count=%d",[self retainCount]); and it logs 6 in when its viewDidLoad is called. Is this correct? 回答1: The retainCount is the number of ownership claims there are outstanding on the object. You take ownership of an object if you create it using a method whose name begins with “alloc” or “new” or contains “copy” (for example, alloc, newObject, or mutableCopy), or if you send