nil error when attempting to set textfield placeholder, segment uiview

75 views Asked by At

xcode v:9.2

I am trying to load user information from the database to set as placeholder text. I have tested this code on a simpler project that does not have segment views, and it works fine. I did some research and I think it might be a hierarchical issue. I am struggling to understand how I can make the textfield values load so that the locations they point to are connected when I try to access them and set placeholder values.

GetCurr retrieves database values and sends them to completion handler function to write placeholder value. When run, "setPH = nil"

Calls GetCurr for email

Completion handler that sets placeholder text

loadUserView should tell when to load the values of this particular segment

I know it's not my IBOutlets because they are all connected and as previously said, this code works perfectly fine in a simpler app that does not have segment views.

1

There are 1 answers

0
cycaMq On

I figured it out! I connected the segments to uiviews that had their own uiviewcontroller class, as subclasses of the parent base class. It also makes my code cleaner and prettier!

Useful: https://docs.swift.org/swift-book/LanguageGuide/Inheritance.html https://cocoacasts.com/managing-view-controllers-with-container-view-controllers/