D
D
Dima Grib2020-12-10 14:08:07
iOS
Dima Grib, 2020-12-10 14:08:07

Passing UIImage from struct to ViewController?

Greetings guys
Tell me how to correctly pass UIImage / or Data from the structure to the ViewController
The logic is as follows

1. In the ViewController, the method from the structure catches the url

func showAll() {
        GetManager.showContent(pasteboard: link)
}


2. The method from the structure validates it, parses JSON and receives a response from the server with files in base64
Alamofire.request(postURL, method: .post, parameters: parameters, encoding: URLEncoding.default).responseJSON { response in
switch response.result { ...
}
}


3. After that, the decoding methods to video and image are triggered
static func base64toImage(base64String: String?) -> UIImage{
}
static func base64toVideo(base64String: String?) {
}


4. How to properly pass UIImage and Video to ViewController. I would not like to update something through notification. What are not crutch options?

5. And how to refine the video decoding method. What would also be returned through return, like image ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Cherny, 2020-12-11
@freeg0r

Do you have a data structure model? Injected into ViewController?
Create a weak variable in the structure that will contain a reference to the ViewController and call its methods.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question