ios - Unowned Reference causes leak , weak doesn't -


i'm experiencing kind of memory management issue. have subclass of uiviewcontroller , set view manually in order have reference viewcontroller , avoid reference cycle use weak/unowned. problem , if use unowned have memory leak if use weak don't have one. can't figure out why happens?

update: seems it's bug.

console output:

removing vc view controller deinitialized custom view deinitialized 

i'm using xcode 8.3.1

func application(_ application: uiapplication, didfinishlaunchingwithoptions launchoptions: [uiapplicationlaunchoptionskey: any]?) -> bool {      window = uiwindow(frame: uiscreen.main.bounds)     window?.rootviewcontroller = viewcontroller(nibname: nil, bundle: nil)     window?.makekeyandvisible()      dispatchqueue.main.asyncafter(deadline: .now() + 5) {          print("removing vc")         self.window?.rootviewcontroller = nil     }      return true }   class viewcontroller: uiviewcontroller {      override func loadview() {         view = customview(frame: .zero, vc: self)         view.backgroundcolor = .red     }      deinit {         print("view controller deinitialized")     } }  class customview:uiview{      init(frame: cgrect , vc:viewcontroller) {         self.vc = vc         super.init(frame: frame)     }      required init?(coder adecoder: nscoder) {         fatalerror("init(coder:) has not been implemented")     }      //    weak var vc : viewcontroller!   // no leak     unowned var vc : viewcontroller   // leak      deinit {         print("custom view deinitialized")     } } 

xcode 8.2 release notes:

the memory debugger macos , ios simulator fixes reporting of false memory leaks swift classes containing either fields of type enum, or classes inherit objective-c framework classes. (27932061)


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -