et moi
et moi

Reputation: 127

Update view using variable

Im attempting to update a view in another classes using a variabes but for some strange reason i get a fatal error: unexpectedly found nil while unwrapping an Optional value. The function works when called from the page where the view exist but not anywhere else. Is there something i'm doing wrong?

     func updateView(trackName: String, image: UIImage){
    let view = IntroController()
    view.cardLabel.text = trackName
    view.cardImage.image = image
}




 func startProcess(completionHandler: (Bool) -> ()) -> (){
            getUserData{
                msg in
                if (msg){
                    print("STEP 1: Get User Data Complete")
                    self.getSearchTerms{
                        termRtn in
                        if (termRtn){
                            print("STEP 2: Get Search Terms Complete")
                            self.searchTerms = self.createArray()
                            self.search{
                                msg in
                                if (msg){
                                    print("STEP 3: Search Completed!")
                                    print(parResults.count)
                                    self.downloadImages{ dlComplete in
                                        if (dlComplete){

                                            print("STEP 4: CardImage has been downloaded or created")
                     updateView(trackName: "test1", image: UIImage(named: "test");
                                            completionHandler(true)
                                        }
                                    }

                                }
                            }

                        }
                    }
                }
            }
        }

Upvotes: 0

Views: 34

Answers (1)

Snusmumrikken
Snusmumrikken

Reputation: 300

Since you provided not much code I will still make an attempt to answer. The IntroController you instantiate probably does not have any code in its constructor that loads the actual XiB. So you are trying to reference the view property of the IntroController, that has not loaded its view. Post the content of IntroController if you need more help.

Upvotes: 1

Related Questions