TAG

Combine

  • December 28, 2020
  • December 26, 2020

Introduction to Combine | Connecting to the Web Server with the Combine

This article explains that how to connect to the web server with the Combine. Create the Publisher of the DataTask Create the publisher of the data task to connect to the web server. Two methods are available to create it: func dataTaskPublisher(for: URL) -> URLSession.DataTaskPublisher func dataTaskPublisher(for: URLRequest) -> URLSession.DataTaskPublisher The first method has an argument “URL”. If you want to simply connect to the URL and GET the contents, you can use this method. The second method has an argument “URLRequest”. With “URLRequest”, you can set the method of the HTTP, the body data, the header value and so […]

  • December 27, 2020
  • December 26, 2020

Introduction to Combine | Supporting Combine in a custom class

Combine is a framework to implement asynchronous operations. It is created by Apple, it is also used in Swift Data Binding. It is an important framework. If you new to Combine, see next article. If you want other samples, see following articles. This article explains how to support Combine in a custom class. Adopt to ObservableObject protocol. To make a class to support Combine, adopt to ObservableObject protocol. To notify a changes of properties with Combine, mark the property with @Published attribute. class PlayerStatus : ObservableObject { @Published var name: String = "" @Published var hitPoint: Int = 100 } […]

>Programming Tips From Software Engineer

Programming Tips From Software Engineer

Technical News, Documents and Tips.

CTR IMG