Skip to content

Commit

Permalink
Removed iOS 4 support, no fall backs, always use NSJSONSerialization
Browse files Browse the repository at this point in the history
  • Loading branch information
MKSG-MugunthKumar committed Oct 31, 2012
1 parent e41b7f5 commit 2d50c7f
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 123 deletions.
31 changes: 13 additions & 18 deletions MKNetworkKit/Categories/NSDictionary+RequestEncoding.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,33 @@ -(NSString*) urlEncodedKeyValueString {
if([string length] > 0)
[string deleteCharactersInRange:NSMakeRange([string length] - 1, 1)];

return string;
return string;
}


-(NSString*) jsonEncodedKeyValueString {

if(NSClassFromString(@"NSJSONSerialization")) {
NSError *error = nil;
NSData *data = [NSClassFromString(@"NSJSONSerialization") dataWithJSONObject:self
options:0 // non-pretty printing
error:&error];
if(error)
DLog(@"JSON Parsing Error: %@", error);

return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
} else {
DLog(@"JSON encoder missing, falling back to URL encoding");
return [self urlEncodedKeyValueString];
}
NSError *error = nil;
NSData *data = [NSJSONSerialization dataWithJSONObject:self
options:0 // non-pretty printing
error:&error];
if(error)
DLog(@"JSON Parsing Error: %@", error);

return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
}


-(NSString*) plistEncodedKeyValueString {

NSError *error = nil;
NSData *data = [NSPropertyListSerialization dataWithPropertyList:self
format:NSPropertyListXMLFormat_v1_0
NSError *error = nil;
NSData *data = [NSPropertyListSerialization dataWithPropertyList:self
format:NSPropertyListXMLFormat_v1_0
options:0 error:&error];
if(error)
DLog(@"JSON Parsing Error: %@", error);

return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
}

@end
6 changes: 6 additions & 0 deletions MKNetworkKit/MKNetworkEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
#error MKNetworkKit does not support Objective-C Garbage Collection
#endif

#if TARGET_OS_IPHONE
#ifndef __IPHONE_5_0
#error MKNetworkKit does not support iOS 4 and lower
#endif
#endif

#if ! __has_feature(objc_arc)
#error MKNetworkKit is ARC only. Either turn on ARC for the project or use -fobjc-arc flag
#endif
Expand Down
Loading

0 comments on commit 2d50c7f

Please sign in to comment.