This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"localHtmlSample" ofType:@"html"]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIAlertView *alertView = [[UIAlertView alloc] | |
initWithTitle:@"DefaultStyle" | |
message:@"the default alert view style" | |
delegate:self | |
cancelButtonTitle:@"Cancel" | |
otherButtonTitles:@"OK", nil]; | |
[alertView show]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dispatch_async(dispatch_get_main_queue(), ^{ | |
// This block will be executed asynchronously on the main thread. | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// More at http://code.tutsplus.com/tutorials/networking-with-nsurlsession-part-1--mobile-21394 | |
// More samples at: http://hayageek.com/ios-nsurlsession-example/ | |
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
NSURLSession *session = [NSURLSession sharedSession]; | |
NSURLSessionDataTask *dataTask = [session dataTaskWithURL:[NSURL URLWithString:@"https://itunes.apple.com/search?term=apple&media=software"] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { | |
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; | |
NSLog(@"%@", json); | |
}]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// UIAlertController example. 'UIAlertView' is deprecated: first deprecated in iOS 9.0 - UIAlertView is deprecated. | |
// Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead | |
// More at: http://useyourloaf.com/blog/uialertcontroller-changes-in-ios-8/ | |
- (void) handleError{ | |
UIAlertController *alertController = [UIAlertController | |
alertControllerWithTitle:nil | |
message:@"Incorrect Credentials" | |
preferredStyle:UIAlertControllerStyleAlert]; | |
UIAlertAction *okAction = [UIAlertAction | |
actionWithTitle:NSLocalizedString(@"OK", @"OK action") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (IBAction)fetchGreeting; | |
{ | |
NSURL *url = [NSURL URLWithString:@"http://rest-service.guides.spring.io/greeting"]; | |
NSURLRequest *request = [NSURLRequest requestWithURL:url]; | |
[NSURLConnection sendAsynchronousRequest:request | |
queue:[NSOperationQueue mainQueue] | |
completionHandler:^(NSURLResponse *response, | |
NSData *data, NSError *connectionError) | |
{ |
NewerOlder