ios - Call function pushing UIViewController inside closure as though it were outside -


i have closure (handlementiontap) inside 2 other closure (entiredescview.customize (2nd closure) , description (1st closure)). call function pushprofilecontroller(of: string) located in same class (in order push view controller (newcontroller). functions need called inside closure since calling them outside causes memory leaks reason don't know (i using library called activelabel, didn't write myself). however, newcontroller not pushed (even though use dispatchqueue.main.async suggested in answers on stackoverflow concerning similar problems). nevertheless newcontroller appears created , data set (i printing data using var passeddata: string? { didset { print(passeddata) } } ). how can push controller though outside closure (e.g. self.pushprofilecontroller(of: username)? appreciate help!

swift (everyhting in same class):

var pushingviewcontroller = false  //...  func pushprofilecontroller(of: string) {     if self.pushingviewcontroller == false {         self.pushingviewcontroller = true         dispatchqueue.main.async {             let newcontroller = newcontroller()             newcontroller.passeddata = of //passeddata string             self.navigationcontroller?.pushviewcontroller(newcontroller, animated: true)         }          self.pushingviewcontroller = false     } }  let description: activelabel = {      let entiredescview = activelabel()      //set properties of controls container view      //recognize (@hotel_x) , able push controller of 'hotel_x'     entiredescview.customize({ (entiredescview) in         entiredescview.enabledtypes = [.mention]         entiredescview.mentioncolor = uicolor(red: 25/255, green: 153/255, blue: 1, alpha: 1)         entiredescview.handlementiontap { username in             self.pushprofilecontroller(of: username) //also tried thisclass().pushprofilecontroller(of: username) didn't push controller either         }     })      return entiredescview  }() 

have checked navigationcontroller? exists?

try adding following before attempting push viewcontroller:

func pushprofilecontroller(of: string) {     if self.pushingviewcontroller == false {         self.pushingviewcontroller = true         dispatchqueue.main.async {             guard let navcontroller = self.navigationcontroller else { return print("navigationcontroller nil") }             let newcontroller = newcontroller()             newcontroller.passeddata = of //passeddata string             navcontroller.pushviewcontroller(newcontroller, animated: true)         }          self.pushingviewcontroller = false     } } 

Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -