0

The documentation for uploadTaskWithRequest:fromData: says about its request parameter:

The body stream and body data in this request object are ignored.

Why is the body data ignored? Why not use it instead of requiring it to be passed separately via the second parameter?

ma11hew28
  • 121,420
  • 116
  • 450
  • 651

2 Answers2

1

In the 2013 WWDC session What's New in Foundation Networking (about 8 and a half minutes in), they talk about "encouraging the separation of data from the meta data" making the "NSURLRequest + payload" pattern analogous to the "NSURLResponse + payload" pattern.

I don't necessarily have any complaint about what they've done with NSURLSessionUploadTask, but I do wonder why they've done it with upload tasks, but neither data nor download tasks.

But it strikes me as a matter of speculation, probably not suited for Stack Overflow. Maybe you can inquire on Apple's development forums.

Rob
  • 415,655
  • 72
  • 787
  • 1,044
0

I'm not sure, but by passing the body data separately the compiler can make sure it's not nil—otherwise, that check can only be done during run-time—thus preventing crashes.

ma11hew28
  • 121,420
  • 116
  • 450
  • 651