Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xiulan's Homework #18

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
Binary file added TalkinToTheNet/.DS_Store
Binary file not shown.
25 changes: 25 additions & 0 deletions TalkinToTheNet/TalkinToTheNet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
8D7DCD541BAF859400A92AD2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8D7DCD521BAF859400A92AD2 /* Main.storyboard */; };
8D7DCD561BAF859400A92AD2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8D7DCD551BAF859400A92AD2 /* Assets.xcassets */; };
8D7DCD591BAF859400A92AD2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8D7DCD571BAF859400A92AD2 /* LaunchScreen.storyboard */; };
D9DEF2D11BB607E10085F47E /* APIManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D9DEF2D01BB607E10085F47E /* APIManager.m */; settings = {ASSET_TAGS = (); }; };
D9DEF2D41BB608E00085F47E /* PlaceResult.m in Sources */ = {isa = PBXBuildFile; fileRef = D9DEF2D31BB608E00085F47E /* PlaceResult.m */; settings = {ASSET_TAGS = (); }; };
D9DEF2D71BB61AEB0085F47E /* DetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D9DEF2D61BB61AEB0085F47E /* DetailViewController.m */; settings = {ASSET_TAGS = (); }; };
D9DEF2E01BB631C50085F47E /* MikeInstagramPost.m in Sources */ = {isa = PBXBuildFile; fileRef = D9DEF2DF1BB631C50085F47E /* MikeInstagramPost.m */; settings = {ASSET_TAGS = (); }; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -26,6 +30,14 @@
8D7DCD551BAF859400A92AD2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
8D7DCD581BAF859400A92AD2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
8D7DCD5A1BAF859400A92AD2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
D9DEF2CF1BB607E10085F47E /* APIManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIManager.h; sourceTree = "<group>"; };
D9DEF2D01BB607E10085F47E /* APIManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APIManager.m; sourceTree = "<group>"; };
D9DEF2D21BB608E00085F47E /* PlaceResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlaceResult.h; sourceTree = "<group>"; };
D9DEF2D31BB608E00085F47E /* PlaceResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlaceResult.m; sourceTree = "<group>"; };
D9DEF2D51BB61AEB0085F47E /* DetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DetailViewController.h; sourceTree = "<group>"; };
D9DEF2D61BB61AEB0085F47E /* DetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DetailViewController.m; sourceTree = "<group>"; };
D9DEF2DE1BB631C50085F47E /* MikeInstagramPost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MikeInstagramPost.h; sourceTree = "<group>"; };
D9DEF2DF1BB631C50085F47E /* MikeInstagramPost.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MikeInstagramPost.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -62,6 +74,14 @@
8D7DCD4D1BAF859400A92AD2 /* AppDelegate.m */,
8D7DCD4F1BAF859400A92AD2 /* ViewController.h */,
8D7DCD501BAF859400A92AD2 /* ViewController.m */,
D9DEF2CF1BB607E10085F47E /* APIManager.h */,
D9DEF2D01BB607E10085F47E /* APIManager.m */,
D9DEF2D21BB608E00085F47E /* PlaceResult.h */,
D9DEF2D31BB608E00085F47E /* PlaceResult.m */,
D9DEF2D51BB61AEB0085F47E /* DetailViewController.h */,
D9DEF2D61BB61AEB0085F47E /* DetailViewController.m */,
D9DEF2DE1BB631C50085F47E /* MikeInstagramPost.h */,
D9DEF2DF1BB631C50085F47E /* MikeInstagramPost.m */,
8D7DCD521BAF859400A92AD2 /* Main.storyboard */,
8D7DCD551BAF859400A92AD2 /* Assets.xcassets */,
8D7DCD571BAF859400A92AD2 /* LaunchScreen.storyboard */,
Expand Down Expand Up @@ -149,9 +169,13 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D9DEF2D11BB607E10085F47E /* APIManager.m in Sources */,
8D7DCD511BAF859400A92AD2 /* ViewController.m in Sources */,
D9DEF2E01BB631C50085F47E /* MikeInstagramPost.m in Sources */,
D9DEF2D41BB608E00085F47E /* PlaceResult.m in Sources */,
8D7DCD4E1BAF859400A92AD2 /* AppDelegate.m in Sources */,
8D7DCD4B1BAF859400A92AD2 /* main.m in Sources */,
D9DEF2D71BB61AEB0085F47E /* DetailViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -300,6 +324,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
// LearnAPI
//
// Created by Xiulan Shi on 9/20/15.
// Copyright © 2015 Xiulan Shi. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface APIManager : NSObject

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

@end
29 changes: 29 additions & 0 deletions TalkinToTheNet/TalkinToTheNet/APIManager.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// APIManager.m
// LearnAPI
//
// Created by Xiulan Shi on 9/20/15.
// Copyright © 2015 Xiulan Shi. All rights reserved.
//

#import "APIManager.h"

@implementation APIManager

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

NSURLSession *session = [NSURLSession sharedSession];

NSURLSessionDataTask *task = [session dataTaskWithURL:URL completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {

dispatch_async(dispatch_get_main_queue(), ^{
completionBlock(data, response, error);
});
}];

[task resume];
}

@end
Loading