0

I linked a TableViewController from storyboard to a class. In a different class I implemented some network request functionality and I would like, as soon as I receive responses, update data in my TableViewController-Class. Is there any way I can address this specific instance of class that contains the table etc.? One way to solve this problem is to access a field of the NetworkClass by implementing a Timer in the TVC-Class, it works, but is probably not the best way to solve the problem. Is there a way to get e.g. an id of a class and a function that lets me create an object with this id, so that I can simply access field and methods of it

Thanks in advance

Julian

Julian Re
  • 1,023
  • 1
  • 8
  • 10
  • 1
    Create a delegate protocol in the network class which your tableviewcontroller implements. – onnoweb Feb 28 '18 at 01:03
  • You should write all network request call methods to different class, call that method from your TableViewController and using block pattern you can achieve your task, let me know if you want any suggestion – PPL Feb 28 '18 at 05:19
  • Thanks for your replies! I managed to solve it by using a protocol, worked out really well! @PPL maybe I'm wrong, but when using block pattern (=Callback functions?) "the call" still comes from the TableViewController, so I would still need to call it repeatedly to see if data has changed right? By using protocols the TableViewController gets "pushed" when something occurs, instead of the TableViewController repeatedly "pulling" something... – Julian Re Feb 28 '18 at 10:28

0 Answers0