Objective-C
Objective-C
Example: Http.QuickGetStr method
Demonstrates theQuickGetStr method.
Chilkat Objective-C Downloads
#import <CkoHttp.h>
#import <NSString.h>
CkoHttp *http = [[CkoHttp alloc] init];
// Keep the response body if there's an error.
http.KeepResponseBody = YES;
// Send the HTTP GET and return the content in a string.
NSString *str = [http QuickGetStr: @"https://www.chilkatsoft.com/helloWorld.json"];
if (http.LastMethodSuccess == NO) {
if ([http.LastStatus intValue] == 0) {
// Communications error. We did not get a response.
NSLog(@"%@",http.LastErrorText);
}
else {
NSLog(@"%@%d",@"Response status code: ",[http.LastStatus intValue]);
NSLog(@"%@",@"Response body error text:");
NSLog(@"%@",http.LastResponseBody);
}
return;
}
NSLog(@"%@",str);
NSLog(@"%@",@"Success");