Questions tagged [deinit]

Swift programming language object destructor

A deinitializer is called immediately before a class instance is deallocated. You write deinitializers with the deinit keyword, similar to how initializers are written with the init keyword. Deinitializers are only available on class types.

102 questions
0
votes
0 answers

how can i deallocate viewControllers in ios

I made some views ordering like Login -> Navigation Controller[Dashboard -> Detail] In LoginViewController, There is Login Button and it has Action @IBAction func loginTapped(_ sender: Any){ let mainNavigationController =…
PrepareFor
  • 2,448
  • 6
  • 22
  • 36
0
votes
1 answer

Asynchronous function call conflicts with deinitialization of an unowned object

I have code similar to this, related to event handling in an asynchronous context: class A { var foos: Set } protocol Fooable { func bar() } class B { var a: A var foo: Foo! init(a: A) { self.a = a } …
Raphael
  • 9,779
  • 5
  • 63
  • 94
0
votes
1 answer

What exactly is deinit doing here? And why?

My Question has to do with the sample code provided for Firebase. You can find it on Github or in the Documentation. Anyway, I don't really understand what the "deinit" on the database reference is doing. I read the deinit swift documentation here.…
DoesData
  • 6,594
  • 3
  • 39
  • 62
0
votes
0 answers

iOS Swift3 ViewController never calls deinit

I have 4 UIViewControllers, all Modally Segued to using Storyboards, all unwind to same root view controller, BUT 1 view controller never calls deinit. I know deinit is not called for this specific VC because I have print statements inside the…
kruskop
  • 11
  • 4
0
votes
1 answer

How to prevent a crash when the uiviewcontroller is deinited and there is an active urlsessiontask

I have a crash in my Swift 3 iOS app when I have an active URLSessionTask and the user presses the back button and the view controller is deinited. I call the cancel method on the urlsessiontask in the back button and no crash occurs at that time…
0
votes
1 answer

Understanding Swift Deinitializers

Swift deinitializer is not updating the valueone and valuetwo, i am getting zero as the answer when i am printing mainTotal.sum, it should update the value and print the answer as 95 struct mainTotal{ static var valueone :Int = 0 static…
user7706553
0
votes
2 answers

Deinit not called in special circumstance that involves NSHashTable

I came across something that's peculiar and interesting and would love to get inputs from anyone. So to start off with lets take this definition of the class: class TestClass:NSObject { var s1 = NSHashTable(options: .weakMemory) …
0
votes
2 answers

Deinit called twice

This seems to appear on two controllers in our project. I checked both code and storyboards and the segue in the storyboard is NOT called in the controller, there is no IBAction nor IBOutlet related to the buttons that will trigger the segue. Though…
thibaut noah
  • 1,474
  • 2
  • 11
  • 39
0
votes
0 answers

ViewController's deinit not called after segue

I have two test controllers: TestController1 and TestController2. I'm trying to deinit first controller when second controller loaded or appeared by changing UIApplication.shared.window[0].rootViewController to self (TestController2). But nothing is…
Denis Petrov
  • 47
  • 1
  • 8
0
votes
1 answer

Swift 3 TableViewController does not deinit

My Swift 3 iOS App Starts with a LoginViewController, which segues to a TabBarController, which has 3 ChildViews, each one is a NavigationController being the rootView to a ViewController. One ViewController contains a Logout Button, which performs…
Jochen Österreicher
  • 683
  • 2
  • 11
  • 25
0
votes
2 answers

How do I handle this initializer?

Create a class called Parent with a title property and write an init and deinit method for your class. Write a subclass called Child. My problem is putting this into the code (call super.init(title:) and pass on the title parameter. class Parent { …
AllocSystems
  • 1,049
  • 2
  • 11
  • 16
0
votes
0 answers

deinit does not get called in my own wrapper class swift

I am writing a wrapper over AVPlayer(say 'MyPlayer') and I have everything in control.I am adding observers on playerItem and MyPlayer.This is what happens: SomeViewController.swift let player_ = Myplayer.player() player_!.delegate = self …
Reckoner
  • 1,041
  • 2
  • 13
  • 29
0
votes
1 answer

UINavigationController deinit never called

From some ViewController of my UINavigationController stack I present another ViewController and will never come back, but the problem is that deinit{} is not called. How should I remove each ViewController from the stack before navigation? Or…
JuicyFruit
  • 2,638
  • 2
  • 18
  • 35
0
votes
1 answer

AVPlayerViewController Doesn't Deallocate After Unwind

In my tvOS app, I have an AVPlayerViewController, presented via a show segue, that shows an alert and unwinds to the previous view if no videos are found. I create an alert controller, present it, and call the unwind segue on the alert action…
Andrew Cox
  • 13
  • 2
0
votes
1 answer

unwind delegate does not deinit a "middle" view

I have a Navigation Controller (NC) and three ViewControllers (A, B, C) with the following navigation pattern: NC->A->B->C If I go from A to C and 'back' both B and C deinit method gets called. If I use an Unwind Segue to go from C to A, B deinit…
zevij
  • 2,416
  • 1
  • 23
  • 32