retain

alloc + init with synthesized property - does it cause retain count to increase by two?

老子叫甜甜 提交于 2019-12-03 11:23:35
问题 I've seeen the following snippet quite a bit: In the header: SomeClass *bla; @property(nonatomic,retain) SomeClass *bla; In the implementation file: @synthesize bla; and then self.bla = [[SomeClass alloc] init]; I think that this assignment puts the retain count for 'bla' up by two; once through the alloc/init call, then through the retain that we asked to happen through the synthesized property setter. As a result, I normally declare my properties like this: In the header: SomeClass *_bla; /

sent to deallocated instance

故事扮演 提交于 2019-12-03 11:15:31
问题 Whenever I push a view controller onto my stack, then pop it off, I get this error: *** -[CALayer retainCount]: message sent to deallocated instance <memory address> It seems to happen right after dealloc is called on the view controller that is being popped off and is exclusive to only this view controller. I'm sure the CALayer has something to do with the view itself, as I do not use them. Any ideas? Edit: Here is the backtrace (gdb) bt #0 0x01fcd3a7 in ___forwarding___ () #1 0x01fa96c2 in

Properties in Objective c. copy and retain

烂漫一生 提交于 2019-12-03 09:11:51
What I have read from the apple document retain will increase the retain count by 1 , and release will decrease by 1. This is very much clear to me. But In the case of copy and retain i am a bit confused. Let me explain with the code i am trying. property --- @property(nonatomic, retain) NSMutableString *a; @property(nonatomic, copy) NSMutableString *b; @synthesize a = _a ,b = _b a=[[NSMutableString alloc]initWithString:@"Hello Ankit"]; NSLog(@"a memory location A - %p", &a ); b=[[NSMutableString alloc]initWithString:@"Hello Nigam"]; NSLog(@"a memory location B- %p", &b ); c= [[NSMutableString

alloc + init with synthesized property - does it cause retain count to increase by two?

喜你入骨 提交于 2019-12-03 02:50:00
I've seeen the following snippet quite a bit: In the header: SomeClass *bla; @property(nonatomic,retain) SomeClass *bla; In the implementation file: @synthesize bla; and then self.bla = [[SomeClass alloc] init]; I think that this assignment puts the retain count for 'bla' up by two; once through the alloc/init call, then through the retain that we asked to happen through the synthesized property setter. As a result, I normally declare my properties like this: In the header: SomeClass *_bla; // note the underscore @property(nonatomic,retain) SomeClass *bla; In the implementation file:

sent to deallocated instance

不想你离开。 提交于 2019-12-03 01:40:21
Whenever I push a view controller onto my stack, then pop it off, I get this error: *** -[CALayer retainCount]: message sent to deallocated instance <memory address> It seems to happen right after dealloc is called on the view controller that is being popped off and is exclusive to only this view controller. I'm sure the CALayer has something to do with the view itself, as I do not use them. Any ideas? Edit: Here is the backtrace (gdb) bt #0 0x01fcd3a7 in ___forwarding___ () #1 0x01fa96c2 in __forwarding_prep_0___ () #2 0x01fc10e8 in CFGetRetainCount () #3 0x01cbc770 in CA::release_root_if

iOS 4 blocks and retain counts

喜你入骨 提交于 2019-12-02 13:59:49
I'm just getting started with blocks and Grand Central Dispatch. I've been told (and read in the Apple Documentation ) that any object referenced from within a block gets retained. For instance: ^{ self.layer.transform = CATransform3DScale(CATransform3DMakeTranslation(0, 0, 0), 1, 1, 1); self.layer.opacity = 1; } "self" gets retained so it leaks. To avoid that, I need to assign self to: __block Object *blockSelf = self; and then use blockSelf instead of self inside my block. My question is: what happens when your block has a lot more code and references several objects? Do I need to assign

OK to retain ASIHTTPRequest delegate?

别说谁变了你拦得住时间么 提交于 2019-12-02 10:42:25
Is it OK to retain a delegate of a subclass of ASIHTTPRequest ? I made a subclass of ASIHTTPRequest called JSONRequest . Each instance of JSONRequest is its own delegate, handles the callbacks, and passes them on to jsonDelegate , which is a private property of JSONRequest , and responds to requestFinished:withResult: , where result is an NSDictionary representation of the JSON response. To do this, I overloaded setDelegate: in JSONRequest to do super.delegate = self; self.jsonDelegate = newDelegate . Is it OK to retain jsonDelegate in this case because often jsonDelegate is a view controller,

How to rotate an image in GD Image Library while keeping transparency?

浪尽此生 提交于 2019-12-02 06:26:29
I'm making a skin previewer for my site; I need to rotate parts of an image to create a representation of this for my users to see. The skin is a PNG file, and all parts of it may have transparency or even none at all. I need to be able to rotate this image while keeping any transparency inside the image transparent, while also having the extended borders (You know, the area that wasn't part of the image before it was rotated) transparent. All of my attempts have left a black border around the image itself. Any help? Cut out the piece of the image you want to rotate Rotate preserving alpha

Difference between retain and copy?

岁酱吖の 提交于 2019-11-30 15:38:15
What exactly is the difference between retain and copy? what is its significance on reference counting? I know that when an object is allocated using alloc/retain, reference count goes up by one. so how about using copy? Another question relating to this is, the difference between using @property(nonatomic, retain) and @property(nonatomic,copy)? retain -- is done on the created object, it just increase the reference count. copy -- create a new object Jiraheta Answering your question to the best of my knowledge. First, What exactly is the difference between retain and copy? what is its

TableView with SearchController - DEINIT not called

自闭症网瘾萝莉.ら 提交于 2019-11-30 14:54:29
I have added a search bar and search display controller from the interface builder to my app. I am not able to get it to deinit (dealloc) properly. It is showing the following behavior (swift2, ios9): User doesn't search anything, just selects an item from tableView, DEINIT is called User searches something (or just taps in the search bar), cancel the search, select item from tableView, DEINIT is called User searches something (or just taps the search bar), and selects an item from tableView, DEINIT is NOT called :( The same behaviour occurs if I select "Back" in the navigation controller