(Objective-C) Example: Http.QuickGetSb method
Demonstrates the QuickGetSb method.
#import <CkoHttp.h>
#import <CkoStringBuilder.h>
BOOL success = NO;
CkoHttp *http = [[CkoHttp alloc] init];
// Send the HTTP GET and return the content in a StringBuilder
CkoStringBuilder *sb = [[CkoStringBuilder alloc] init];
success = [http QuickGetSb: @"https://www.chilkatsoft.com/helloWorld.json" sbContent: sb];
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(@"%@",[sb GetAsString]);
}
return;
}
// The downloaded content:
NSLog(@"%@",[sb GetAsString]);
NSLog(@"%@",@"Success");
|