diff --git a/TalkinToTheNet/TalkinToTheNet.xcodeproj/project.pbxproj b/TalkinToTheNet/TalkinToTheNet.xcodeproj/project.pbxproj index ee35a70..26ea0cd 100644 --- a/TalkinToTheNet/TalkinToTheNet.xcodeproj/project.pbxproj +++ b/TalkinToTheNet/TalkinToTheNet.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 5A046ECC1BB67F5400E7C307 /* APIManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 5A046ECB1BB67F5400E7C307 /* APIManager.m */; settings = {ASSET_TAGS = (); }; }; 8D7DCD4B1BAF859400A92AD2 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D7DCD4A1BAF859400A92AD2 /* main.m */; }; 8D7DCD4E1BAF859400A92AD2 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D7DCD4D1BAF859400A92AD2 /* AppDelegate.m */; }; 8D7DCD511BAF859400A92AD2 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D7DCD501BAF859400A92AD2 /* ViewController.m */; }; @@ -16,6 +17,8 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 5A046ECA1BB67F5400E7C307 /* APIManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIManager.h; sourceTree = ""; }; + 5A046ECB1BB67F5400E7C307 /* APIManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APIManager.m; sourceTree = ""; }; 8D7DCD461BAF859400A92AD2 /* TalkinToTheNet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TalkinToTheNet.app; sourceTree = BUILT_PRODUCTS_DIR; }; 8D7DCD4A1BAF859400A92AD2 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 8D7DCD4C1BAF859400A92AD2 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; @@ -62,6 +65,8 @@ 8D7DCD4D1BAF859400A92AD2 /* AppDelegate.m */, 8D7DCD4F1BAF859400A92AD2 /* ViewController.h */, 8D7DCD501BAF859400A92AD2 /* ViewController.m */, + 5A046ECA1BB67F5400E7C307 /* APIManager.h */, + 5A046ECB1BB67F5400E7C307 /* APIManager.m */, 8D7DCD521BAF859400A92AD2 /* Main.storyboard */, 8D7DCD551BAF859400A92AD2 /* Assets.xcassets */, 8D7DCD571BAF859400A92AD2 /* LaunchScreen.storyboard */, @@ -149,6 +154,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 5A046ECC1BB67F5400E7C307 /* APIManager.m in Sources */, 8D7DCD511BAF859400A92AD2 /* ViewController.m in Sources */, 8D7DCD4E1BAF859400A92AD2 /* AppDelegate.m in Sources */, 8D7DCD4B1BAF859400A92AD2 /* main.m in Sources */, @@ -300,6 +306,7 @@ 8D7DCD5F1BAF859400A92AD2 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/TalkinToTheNet/TalkinToTheNet/APIManager.h b/TalkinToTheNet/TalkinToTheNet/APIManager.h new file mode 100644 index 0000000..b9d51be --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/APIManager.h @@ -0,0 +1,17 @@ +// +// APIManager.h +// LearnAPIS +// +// Created by Brian Blanco on 9/20/15. +// Copyright © 2015 Brian Blanco. All rights reserved. +// + +#import + +@interface APIManager : NSObject + ++ (void)GETRequestWithURL:(NSURL *)URL + completionHandler:(void(^)(NSData *data, NSURLResponse *response, NSError *error)) + completionHandler; + +@end diff --git a/TalkinToTheNet/TalkinToTheNet/APIManager.m b/TalkinToTheNet/TalkinToTheNet/APIManager.m new file mode 100644 index 0000000..939cac4 --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/APIManager.m @@ -0,0 +1,31 @@ +// +// APIManager.m +// LearnAPIS +// +// Created by Brian Blanco on 9/20/15. +// Copyright © 2015 Brian Blanco. All rights reserved. +// + +#import "APIManager.h" + +@implementation APIManager + ++ (void)GETRequestWithURL:(NSURL *)URL + completionHandler:(void(^)(NSData *data, NSURLResponse *response, NSError *error)) +completionHandler { + + NSURLSession *session = [NSURLSession sharedSession]; + NSURLSessionDataTask *task = [session dataTaskWithURL:URL completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { + + NSLog(@"%@",data); + + dispatch_async(dispatch_get_main_queue(), ^{ + completionHandler(data, response, error); + + }); + }]; + + [task resume]; +} + +@end