0

I've been struggling for a while with the following swift 4 code : it appears that during the execution (or debug), the lines 89 to 102 are not executed, as if it was some comments... Hence, my array of data is empty so I can't deserialized and use them. Any ideas about why it behaves like that ? Hope my question is pertinent... Thanks :)

Code with line numbers

Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
Jean
  • 5
  • 3
  • You should include your code as text so that users don't need to click a link to help you. you have a guard statement there so I would guess either data is nil or error is not. Also you are trying to return before the async function would complete. – Scriptable Jun 20 '18 at 12:21
  • `URLSession.dataTask` is asynchronous, hence your "issue". This is the expected behaviour, since the completion handler is only called once the network request returns asynchronously. – Dávid Pásztor Jun 20 '18 at 12:22
  • Ok thx guys ! Since it's asynchronous, how can i wait ? Should i delete my post since the question doesn't seem pertinent ? – Jean Jun 20 '18 at 12:24

0 Answers0