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
1 answer

Memory management issue using Swift

We are having some memory allocation issues. When I am run my app and come to a certain page, the Memory count is increased by 30mb each time I come to the page. I have added IBOutlets as Weak and declared variables as ? (i.e. Optionals), though…
dhaval shah
  • 4,499
  • 10
  • 29
  • 42
0
votes
1 answer

Swift: UIViewController doesn't auto deiniting

I added to my UIViewController the code below: deinit { print("DEINIT") } And then i used the code below: let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil) let nextViewController =…
Dror Chen
  • 51
  • 1
  • 10
0
votes
1 answer

Can we use deinitialized variables in code, or are they pretty much useless because they are deallocated right after?

Im a little confused on the topic of deallocation when comparing it to deinitaizlization. Doesn't deallocation happen the moment after a variable is deinitialized.....My main point here is, Could we use/manipulate deinitialized variables somehow? or…
Ali
  • 505
  • 4
  • 12
0
votes
0 answers

SCNAction.removeFromParentNode and deinit not called

the following method is defined inside a class extension of GKComponent weak var node:SCNNode? ... func moveAlongNorthSouth() { let moveAction = SCNAction.moveByX(0, y: 0, z: 1, duration: NSTimeInterval(2)) let sequence =…
chiarotto.alessandro
  • 1,491
  • 1
  • 13
  • 31
0
votes
0 answers

Why memory increase and decrease suddenly although I do anything in my sprite kit game?

I am developing a simple game with sprite kit. When I run the game on my device I start to change scenes between gameplay, main scene and level scene.However, memory increase in gameplay but 5 times increase unexpectedly and automatically decrease…
Çağatay Kaya
  • 417
  • 1
  • 6
  • 19
0
votes
1 answer

Ad Hoc Navigation Using iOS Storyboard Segues

I have 3 view controllers: Main, List and Run. (More will be added later.) I'm using storyboards and segues. The target OS is iOS 8. Main is the initial scene/controller. At present, I am not using any navigation controllers. A button on Main…
Bruce L
  • 229
  • 2
  • 3
0
votes
3 answers

Can a child object refer to its parent during deinit of the parent?

I have a parent class and a child class. The parent has a strong reference to the child, and the child has an unowned reference to the parent. During deinit of the parent, I want the child to do some cleaning up, and that involves calling the…
JimmyB
  • 326
  • 3
  • 12
0
votes
0 answers

Why are these swift objects not deinitializing?

I'm working my way through the Swift language reference, and am trying to understand how weak and unowned references are implemented. The code snippet below is in the book, except that I've added println() statements in the initializers as well. …
0
votes
1 answer

Weak object array in Swift

I would like to create an object array as a property of another class in Swift, such as: class person{ var livingInHouse : house name : String } class house{ var personArray : [person] } My constraints are: I would like to easily access the…
darksider
  • 3
  • 1
  • 2
0
votes
0 answers

Does setting an optional instance to nil call deinit (if implemented)?

This might be a crazy question, but its something that has been bugging me this week. In Swift if you have an optional instance of a class does setting that optional to nil call deinit (if implemented) or do any cleanup on the instance? // OPTIONAL…
fuzzygoat
  • 26,573
  • 48
  • 165
  • 294
-1
votes
1 answer

deinit only gets called when view controller opens

This is related to memory leak issues. I have a view controller which displays by calling performSegueWithIdentifier, and closes by calling self.dismissViewController. I have a deinit function inside of this view controller, but it does not get…
jackson
  • 81
  • 1
  • 9
-2
votes
1 answer

Swift : Some classes not de-initialised

In the following code NSString and NSNumber are not de-initialised when the reference is removed . NSMutableString and NSAttributedString are de-initialised . What is the criteria for deinit ? class WeakHolder { weak var cheez :…
user3438934
  • 389
  • 2
  • 10
1 2 3 4 5 6
7