retaincount Questions

11

Solved

I would like to know in what situation did you use -retainCount so far, and eventually the problems that can happen using it. Thanks.
Target asked 8/1, 2011 at 21:7

0

When I do a retain count on this object it is 2. Why is this? Surely it should be one as I have just initialised it and not assigned it or anything... let testC: TestClass = TestClass() print(CFGe...

1

Solved

In other stack overflow questions, it was emphasized that the capture [weak self] should be used for closures that aren't owned by the class because self could be nil before the closure completes. ...
Sofar asked 14/11, 2016 at 7:21

1

Solved

Consider this ARC code: - (void)main { NSString *s = [[NSString alloc] initWithString:@"s"]; [NSApp beginSheet:sheet modalForWindow:window modalDelegate:self didEndSelector:@selector(sheet...

1

Solved

My question is how the current versions of Foundation (or of the Objective-C runtime library, since this seems to be there) implement retain count for NSObject derived objects? As I could see at NS...

5

Solved

Until five minutes I was sure that my understanding about Objective c reference counting is excellent, but when I started checking objects retainCount I was very surprised to see what I saw. For e...
Goodfornothing asked 22/5, 2012 at 11:57

2

Solved

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 interesti...
Refer asked 5/4, 2012 at 16:3

3

Solved

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:(CG...
Correy asked 12/11, 2010 at 10:55

4

Solved

I'm still trying to understand this piece of code that I found in a project I'm working on where the guy that created it left the company before I could ask. This is the code: -(void)releaseMySel...
Saucy asked 16/12, 2011 at 11:11

2

Please explain me the below code of lines, I am just confused.., Nsstring *a; Nsstring *b; a = [b retain]; what is the retain count of a & b. a = [b copy]; what is the retain count of a ...
Lanate asked 17/10, 2011 at 17:5

4

Solved

I would like to know how many times an object has been autoreleased. I've used objective c long enough that it's generally straight forward to know whether an object has been autoreleased or not, h...
Nieshanieto asked 22/9, 2011 at 14:53

2

Solved

Does anybody know how can I check the retain count of an object while in debug mode? I have tried to add an expression [objInstance retainCount] but it did not work. I have also tried the print obj...
Argue asked 10/9, 2011 at 19:12

1

Solved

I am doing this : UIImageView *backgroundImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mainback.jpg"]]; [self.view addSubview:backgroundImage]; NSLog(@" retain count1 : %d " , ...
Trenna asked 20/8, 2011 at 9:50

3

Solved

I'm confused by an occasional crash that I'm seeing, which, according to the Zombies instrument, is caused by the over-release of some dictionary values. When I look at the object history for one o...

2

Solved

Or, Why I Didn't Use retainCount On My Summer Vacation This post is intended to solicit detailed write-ups about the whys and wherefores of that infamous method, retainCount, in order to consolida...
Ichneumon asked 25/4, 2011 at 22:42

2

Solved

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 str...
Magnitogorsk asked 28/9, 2010 at 20:43

2

I am making an iPhone game. I want to release all objects that have been allocated or retained. In the dealloc function I am releasing all such objects, but then I realized that sometimes I end up ...

5

Solved

The method retainCount is supposed to return an unsigned integer. Why then, does [@"Hi" retainCount] return -1?
Fluoresce asked 6/1, 2010 at 17:1

2

Solved

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 call...
Limbert asked 30/7, 2009 at 11:53
1

© 2022 - 2024 — McMap. All rights reserved.