swiftweak-referencescompletionhandler

self refrence inside swift closure return nil some time


I am accessing instance method inside closure in swift, self reference become nil in some cases which result crash my program. I tried to access using [weak self] but it failed to call the instance method when self is nil.

[weak self] () -> () in

Solution

  • I am able to fix this issue by making strong instance while creating it, in my case this weak variable was making nil to self. Thanks all for providing suggestion for my queries.