Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Tin makes the internet easier in Cocoa.
branch: master

This branch is 1 commit behind pjaspers:master

Added parameter encoding for POST body.

Still defaults to JSON but you can also do URL encoding.
latest commit b527a15681
Tom Adriaenssen authored
Failed to load latest commit information.
Tin.xcodeproj ARCized Tin. Removed JSONKit since were in a new century.
Tin Fixed timestamp format warning.
Vendor/AFNetworking Removed phyiscal JSONKit files.
tests ARCized Tin. Removed JSONKit since were in a new century.
.gitattributes Setting up Tin with tests
.gitignore Setting up Tin with tests
README.mdown minor readme update
Rakefile
Tin.h Added parameter encoding for POST body.
Tin.m Added parameter encoding for POST body.
Tin.podspec Correct the description/tin source

README.mdown

Tin

Tin aims to make talking to webservices from Cocoa a lot simpler. It uses blocks and (the excellent HTTP library) AFNetworking to make requests look simple.

Why?

My previous API attempts always used a lot of delegates, which we needed since we didn't have blocks and synchronous requests is definitely not the way to go in a desktop app.

Now with blocks it's finally possible to make it look like this:

[Tin get:@"http://apple.com" success:(TinResponse *response) {
  NSLog(@"Response: %@", response.response);
  NSLog(@"Headers: %@", response.headers);
}];

How to install?

The simplest way to install (as long as I don't create downloads of it) will be to clone the project and copy the Tin header files and the Tin subfolder into your own project.

Tin has one big dependency and that is AFNetworking so make sure to have that installed as well.

Usage

There are two ways to use Tin, the simplest way is to always call the class methods (e.g. [Tin get:...];), the downside of this is you don't get some of the goodies the instance methods can use.

For example if you create a:

Tin *tin = [[Tin alloc] init];
tin.baseURI = @"http://tin.com";

You can do your requests as such: [tin get:@"/something/else" success:nil]; which will route the request to http://tin.com/something/else. So if you keep that instance around in a handy place, it might save you a lot of typing.

At the moment Tin supports the following methods:

  • GET
  • POST
  • PUT

Each of these support both a query and a body argument to pass on data. If you pass a NSDictionary to query it will be converted to a string containing its keys and values. E.g.

NSDictionray *dict = [NSDictionary dictionaryWithObjectsAndKeys:@"string", @"key", nil];
// would be converted to an NSString
@"key=string"

Al other objects will get their description method called to get their string representation to pass on to ASI.

Tests

Normally a rake test should run all the unit tests. At the moment most of them still have a dependency on a network connection being up, but I'm refactoring that to go away (see TinTest.m)

Can I help?

Please do!

Fork it! Improve it! Test it! Rewrite it! (technology)

Something went wrong with that request. Please try again.