retain-cycle Questions

1

Edit: Created a sample project illustrating the issue: https://github.com/Harold-D/PDFView_Representable Question: I'm at a lost, I have this very simple UIViewRepresentable wrapper around PDFView ...
Seafood asked 16/10, 2021 at 21:23

7

Solved

UIView.animateWithDuration(1, animations: { [unowned self] in self.box.center = self.boxTopRightPosition }, completion: { [unowned self] completed in self.box.hidden = true }) Is it necess...
Amarillas asked 19/11, 2014 at 14:45

10

Solved

I'm using an NSTimer like this: timer = [NSTimer scheduledTimerWithTimeInterval:30.0f target:self selector:@selector(tick) userInfo:nil repeats:YES]; Of course, NSTimer retains the target which ...
Croaker asked 29/5, 2013 at 18:54

11

In my TextViewTableViewCell, I have a variable to keep track of a block and a configure method where the block is passed in and assigned. Here is my TextViewTableViewCell class: // // TextViewTab...
Semele asked 28/6, 2014 at 15:33

2

Solved

In ReactiveCocoa there is macro to prevent retain cycle @weakify and @strongify. From my understanding @weakify do something like what I usually do that is create __weak reference for using in the ...
Semifluid asked 2/3, 2015 at 11:53

2

Solved

As Apple said in "The Swift Programming Language", it seems we should prefer unowned than weak whenever possible: If the captured reference will never become nil, it should always be captured a...
Spermatic asked 19/8, 2014 at 7:20

10

Solved

Lets say we have three objects: a grandparent, parent and child. The grandparent retains the parent, the parent retains the child and the child retains the parent. The grandparent releases the pare...

3

Solved

Assuming I have following code: struct X { let propertyOfTypeY: Y } class Y { var propertyOfTypeX: X? } let y = Y() let x = X(propertyOfTypeY: y) y.propertyOfTypeX = x If these were both cla...
Lymphangial asked 6/3, 2017 at 17:39

1

Solved

I am confused about using self inside a closure. When should we declare [weak self] ? An obvious case that I understand is class Foo{ var closure: ( Void -> Void )? var x = 0 func doSome...
Hungnam asked 18/7, 2015 at 4:34

2

Solved

I can't figure out if I need to use [weak self] in this situation or not ? HTTPClient.swift: struct HTTPClient { let session = URLSession.shared func get(url: URL, completion: @escaping (Dat...
Greybeard asked 25/11, 2018 at 20:28

1

Solved

I just want to know if I am understanding this correctly or not. So according to the apple docs when you create a closure as a property of a class instance and that closure references self(The clas...
Aboveboard asked 9/5, 2018 at 20:11

2

Solved

I'm having trouble tracking down a retain cycle. I think it's to do with the way I subscribe to events. Pseudo code is like this: override func viewDidLoad() { func handleEvent() { self.doSometh...
Anuria asked 20/12, 2017 at 17:38

3

Solved

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"alert" message:nil preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *action = [UIAlertAction actionWithTitle:@"act...

1

Solved

I have ready many (if not all) articles on SO and other sites about the disasters of dealing with SpriteKit and memory issues. My problem, as many others have had, is after i leave my SpriteKit sce...

1

Solved

I am having trouble destroying viewcontrollers due what I believe to be a retain cycle between a collectionview and the viewcontroller. I tried making the collectionview a weak variable but I am no...
Hermit asked 2/11, 2017 at 19:57

1

Solved

I am trying to better understand retain cycles, especially relative to Dispatch Queues. I am working with AVFoundation and managing an AVCaptureSession on a sessionQueue: private let sessionQueue ...
Faddist asked 1/3, 2017 at 21:7

2

Solved

In one of my classes I use an array of delegates (the class is a singleton). This is causing an retain cycle. I know I can avoid the retain cycle when I use only one delegate by making the de...
Gauthier asked 25/2, 2017 at 14:53

1

Solved

I was wondering if there was an easy way (or at least a way) to find out where retain cycles exist in your program. Also, if I then know where these retain cycles exist, depending on their types (e...
Graphy asked 15/1, 2017 at 11:16

2

If I have a closure in another closure is it enough to use unowned/weak once in the outer closure to avoid retain cycles? Example: foo.aClosure({[unowned self] (allowed: Bool) in if allowed { s...
Pavlodar asked 15/6, 2016 at 14:8

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

3

Solved

There are some retain cycle in my iOS application. For a particular viewController, stuck in a retain cycle, I have tried making all delegates weak. But when I simulate memory warning from simula...
Actinia asked 21/12, 2015 at 13:30

4

Solved

I'm trying to correctly avoid retain cycles with blocks in Objective C, and am not sure about having nested blocks. If I write a simple block like this: [self doSomethingWithBlock:^{ [self doSom...
Resumption asked 8/8, 2016 at 18:7

2

Solved

PromiseKit states the following on their website: Should I be concerned about retain cycles? tl;dr: it’s safe to use self in promise handlers. This is safe: somePromise.then { self.doSom...
Piled asked 1/9, 2016 at 21:34

3

Solved

Can anyone please explain why this doesn't leak? I'm capturing self within a closure so I would have two strong pointers pointing at each other, therefore, the deinit message shouldn't ever be ca...
Pyretotherapy asked 10/8, 2016 at 14:39

3

Solved

I have never worked on non ARC based project. I just came across a zombie on my ARC based project. I found it was because of retain cycle.I am just wondering what is a retain cycle.Can Could you ...
Pahari asked 9/10, 2012 at 14:34

© 2022 - 2024 — McMap. All rights reserved.