This file contains 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) | |
{ |
This file contains 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 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 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 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 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 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
- (NSURL *)applicationDocumentsDirectory { | |
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; | |
} |
This file contains 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
var appDelegate = UIApplication.sharedApplication().delegate as AppDelegate |
This file contains 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
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
// Your code here | |
}); |
This file contains 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
#pragma clang diagnostic push | |
#pragma clang diagnostic ignored "-Wdeprecated-declarations" | |
// Your code here | |
#pragma clang diagnostic pop |
OlderNewer