ios - Weird Error when setting detailItem in DetailViewController from MasterViewController -


i started getting error randomly (may due updating swift) when reach, didset in detailitem, call configureview. in configureview check see if detailitem indeed set , start assigning values outlets.

if let detail: posting = self.detailitem {         print("detail title ")         println(detail.title)          // title         self.titlelabel.text = detail.title 

however crashes output:

detail title skiing in vail fatal error: unexpectedly found nil while unwrapping optional value 

the error on line:

self.titlelabel.text = detail.title 

i don't understand why crashing when is set... note doesn't happen if call configureview within viewdidload.

this happens when call

 var detailitem: posting? {     didset { self.configureview() } } 

something i'm missing? working asynchronously or something?

referencing comment on how implement this, there few trains of thought. first, reason can modify directly mastervc because iboutlet hasn't been instantiated in detailvc , isn't available modified yet.

one option, i'd follow, have helper variable on detail view can place value. viewwillappear() can take whatever's in variable , set label's text. here's tutorial on it, answer specific quesiton please jump prepareforsegue method in tutorial. gives rundown of whole process:

http://www.codingexplorer.com/segue-swift-view-controllers/

let me know if doesn't solve problem.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -