biasedbit / BBHTTP

A modern HTTP client framework for iOS/OSX built on top of libcurl.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Its not clear what BBHTTPResponse.content property is

jasperblues opened this issue · comments

I want my response as NSData . . . reading the docs shows content type is 'id'. . .this is confusing.

The content type of the response will be whatever the response content handler produces so it can be NSData, UIImage, or any other object.

Since objc has no generics, it has to be this way.

How about just adding some info in the API docs. . . What is the default content handler?

PS: When I say 'confusing' - its still way easier to come to grips with than AFNetworking!

How about having some ResponseContent classes?

DefaultResponseContent //content property is typed to NSData

Then, In setup you could :

[setResponseContentClass:[BBImageResponseContent class]] //Content property is typed to UIImage

This way you have:

  • Strong typing that you can look up in the API docs. . .
  • Just two lines up in the setUp block, you can see what kind of response you'll be getting.

This way it should be possible to drive the API with IDE code completion without having to remember the details or read the docs. . .

(Just a random idea).

Ah, OK. . . I can see now that it pretty much already works as per my suggestion above. . . Except that the short-hand API obfuscates this a bit. . .

It really depends on the response content handler. I'd rather have the user provide a response content handler than pass a class that will later map to a response content handler. Seems more straightforward.

Thanks for the feedback.