O
O
OPIO2016-01-29 16:39:58
iOS
OPIO, 2016-01-29 16:39:58

Is it possible to create a single NSURLConnection call method for the entire application?

Good day!
Essence of the question: the IOS application has several different ViewControllers, let's say 5, each is processed by its own class, and in 3 of them the same structure of requesting data from the server is processed:

NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
and further processing of the response in methods: - (void)connection:...
How can this design be optimized, for example, so that each ViewController accesses a separate common class with methods, where the logic of requesting data from the server would be processed and the processed response would be returned to the ViewController class?

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
M
ManWithBear, 2016-01-29
@OPIO

Usually, a singleton (or something similar to a singleton with the possibility of emergency re-creation) is created to communicate with the server. In which requests and yurls are encapsulated. The methods take blocks in the parameter to process the response of the server or delegate.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question