Skip to content
Open

hw1 #25

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions TalkinToTheNet/TalkinToTheNet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand All @@ -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 = "<group>"; };
5A046ECB1BB67F5400E7C307 /* APIManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APIManager.m; sourceTree = "<group>"; };
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 = "<group>"; };
8D7DCD4C1BAF859400A92AD2 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -300,6 +306,7 @@
8D7DCD5F1BAF859400A92AD2 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
17 changes: 17 additions & 0 deletions TalkinToTheNet/TalkinToTheNet/APIManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// APIManager.h
// LearnAPIS
//
// Created by Brian Blanco on 9/20/15.
// Copyright © 2015 Brian Blanco. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface APIManager : NSObject

+ (void)GETRequestWithURL:(NSURL *)URL
completionHandler:(void(^)(NSData *data, NSURLResponse *response, NSError *error))
completionHandler;

@end
31 changes: 31 additions & 0 deletions TalkinToTheNet/TalkinToTheNet/APIManager.m
Original file line number Diff line number Diff line change
@@ -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