Static library for simple iOS http networking. Currently a work in progress as I integrate bits and pieces from all of my apps. Plan to implement the following:
-
Requests for all HTTP Verbs (GET/POST/PUT/DELETE)
GET - Basic implementation complete PUT - Basic implementation complete POST - Bastic implementation compelte DELETE - Basic implementation complete
-
Reachability notification handling
Requests which fail due to connection are put into a queue and automatically retried whenever the reachability status changes. TGHTTPClient instances are responsible for their own retry queues. If the client is not retained, no retries will occurr. Requests that fail due to server error execute the block with the appropriate error message.
-
Returns the appropriate ObjC type based on the MIME type of the response
Current implementation will return NSDictionary, NSArray, UIImage, or NSData based on some very simple conditions.
-
cd into your project's repository
-
git submodule add git://github.com/brcosm/TGNetworking.git
-
File > add the .xcodeproj file to your project in Xcode
-
Targets > {Your target} > Build Phases > Target Dependencies > Add
TGNetworking SystemConfiguration
-
Targets > {Your target} > Build Phases > Link Binary With Libraries > Add libTGNetworking.a
-
Targets > {Your target} > Build Settings > Linking > Other Linker Flags > Add
-ObjC -all_load
-
Targets > {Your target} > Build Settings > Search Paths > Header Search Paths > Add (including ")
"$(TARGET_BUILD_DIR)/usr/local/lib/include" "$(OBJROOT)/UninstalledProducts/include"
-
Import with:
#import <TGNetworking/TGNetworking.h>
TGHTTPClient *client = [[TGHTTPClient alloc] initWithHostName:@"localhost" port:@"8000"];
[client getResourceAtPath:@"items.json" callback:^(id obj, NSError *error) {
if ([obj isKindOfClass:[NSDictionary class]]) {
for (NSString *key in [obj allKeys]) NSLog(@"%@", key);
} else if ([obj isKindOfClass:[NSArray class]]) {
for (id o in obj) NSLog(@"%@", [o description]);
} else if (error) {
NSLog(@"%@", error.localizedDescription);
}
}];