1

For example, one UIViewController requests data using AFNetworking on appear event and perform some actions on result receiving. These actions are defined in a block which I give to a request object as a param.

Now I want to add a button which will push another view controller. This view controller will use the same data which the first view controller already uses.

The problem is I don't need to resend the same request for the second one but I'll have some issues with it: 1)I can't set its params directly on request completion because the second view controller may not exist yet 2)If the second one is currently displayed then should I handle the data in the first one?

To handle requests I create NSURLSessionTask object and call showAlertViewForTaskWithErrorOnCompletion:delegate:. It is just two strings of code so I think it is not necessary to post it.

Gargo
  • 1,135
  • 1
  • 10
  • 21

1 Answers1

0

Fundamentally it sounds like you are trying to share data between view controllers. There are multiple solutions to this problem, refer to this answer:

Passing Data between View Controllers

For checking which is the displayed view controller, consult this answer:

How to determine which view controller is currently active/the one displaying a view?

Community
  • 1
  • 1
Andrew Schreiber
  • 14,344
  • 6
  • 46
  • 53
  • Fundamentally you posted some links with theory which are not connected with both AFNetworking or asynchronous calls. – Gargo Jul 27 '14 at 21:21