ios - UIKit<-segue->SpriteKit memory leak -
i enjoy swift, ios development.
i add segue between viewcontroller(for uikit), , viewcontroller(for spritekit).
i run iphone simulator, memory navigator increase 30m per switch viewcontroller.
osx 10.9.5, xcode.6.1.1
- new -> project -> game
- new -> file -> swift file -> firstviewcontroller.swift
- drag viewcontroller library storyboard, set custom class: firstviewcontroller
set arrow firstviewcontroller
select firstviewcontroller, option&drag gameviewcontroller(segue)
- set identifier "togame"
- select gameviewcontroller, option&drag self exit
- set identifier "back"
code:
class firstviewcontroller: uiviewcontroller { @ibaction func returnmenu(segue: uistoryboardsegue) { println("back!") } override func touchesended(touches: nsset, withevent event: uievent) { performseguewithidentifier("togame", sender: nil) } } class gameviewcontroller: uiviewcontroller { override func viewdidload() { super.viewdidload() if let scene = gamescene.unarchivefromfile("gamescene") as? gamescene { scene.viewcontroller = self skview.presentscene(scene) } } } class gamescene: skscene { var viewcontroller: uiviewcontroller? override func touchesbegan(touches: nsset, withevent event: uievent) { touch: anyobject in touches { self.viewcontroller?.performseguewithidentifier("back", sender: nil) } }
thanks.
class gamescene: skscene { weak var viewcontroller: uiviewcontroller? }
thank everyone! weak references! memory leak solved!