diff --git a/TalkinToTheNet/TalkinToTheNet.xcodeproj/project.pbxproj b/TalkinToTheNet/TalkinToTheNet.xcodeproj/project.pbxproj index ee35a70..fe8fa45 100644 --- a/TalkinToTheNet/TalkinToTheNet.xcodeproj/project.pbxproj +++ b/TalkinToTheNet/TalkinToTheNet.xcodeproj/project.pbxproj @@ -7,21 +7,38 @@ objects = { /* Begin PBXBuildFile section */ + 3D0E5F781BB5D40D0031F61E /* SearchVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D0E5F771BB5D40D0031F61E /* SearchVC.m */; }; + 3D0E5F7B1BB5D5F30031F61E /* TableListVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D0E5F7A1BB5D5F30031F61E /* TableListVC.m */; }; + 3D341FD81BB1EAB9002D0D89 /* ListOfPlacesVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D341FD71BB1EAB9002D0D89 /* ListOfPlacesVC.m */; }; + 3D341FDB1BB1EC73002D0D89 /* APIManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D341FDA1BB1EC73002D0D89 /* APIManager.m */; }; + 3D341FDE1BB37847002D0D89 /* LocationObjects.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D341FDD1BB37847002D0D89 /* LocationObjects.m */; }; + 3D341FE01BB46BEB002D0D89 /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D341FDF1BB46BEB002D0D89 /* MapKit.framework */; }; + 3D341FE21BB46FF4002D0D89 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D341FE11BB46FF4002D0D89 /* CoreLocation.framework */; }; 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 */; }; 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 */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 3D0E5F761BB5D40D0031F61E /* SearchVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SearchVC.h; sourceTree = ""; }; + 3D0E5F771BB5D40D0031F61E /* SearchVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SearchVC.m; sourceTree = ""; }; + 3D0E5F791BB5D5F30031F61E /* TableListVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableListVC.h; sourceTree = ""; }; + 3D0E5F7A1BB5D5F30031F61E /* TableListVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TableListVC.m; sourceTree = ""; }; + 3D0E5F7C1BB5DA7C0031F61E /* SearchFieldDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SearchFieldDelegate.h; sourceTree = ""; }; + 3D341FD61BB1EAB9002D0D89 /* ListOfPlacesVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ListOfPlacesVC.h; sourceTree = ""; }; + 3D341FD71BB1EAB9002D0D89 /* ListOfPlacesVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ListOfPlacesVC.m; sourceTree = ""; }; + 3D341FD91BB1EC73002D0D89 /* APIManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIManager.h; sourceTree = ""; }; + 3D341FDA1BB1EC73002D0D89 /* APIManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APIManager.m; sourceTree = ""; }; + 3D341FDC1BB37847002D0D89 /* LocationObjects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocationObjects.h; sourceTree = ""; }; + 3D341FDD1BB37847002D0D89 /* LocationObjects.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LocationObjects.m; sourceTree = ""; }; + 3D341FDF1BB46BEB002D0D89 /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = System/Library/Frameworks/MapKit.framework; sourceTree = SDKROOT; }; + 3D341FE11BB46FF4002D0D89 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; 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 = ""; }; 8D7DCD4D1BAF859400A92AD2 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - 8D7DCD4F1BAF859400A92AD2 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; - 8D7DCD501BAF859400A92AD2 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 8D7DCD531BAF859400A92AD2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 8D7DCD551BAF859400A92AD2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 8D7DCD581BAF859400A92AD2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; @@ -33,6 +50,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 3D341FE21BB46FF4002D0D89 /* CoreLocation.framework in Frameworks */, + 3D341FE01BB46BEB002D0D89 /* MapKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -42,6 +61,8 @@ 8D7DCD3D1BAF859400A92AD2 = { isa = PBXGroup; children = ( + 3D341FE11BB46FF4002D0D89 /* CoreLocation.framework */, + 3D341FDF1BB46BEB002D0D89 /* MapKit.framework */, 8D7DCD481BAF859400A92AD2 /* TalkinToTheNet */, 8D7DCD471BAF859400A92AD2 /* Products */, ); @@ -60,8 +81,17 @@ children = ( 8D7DCD4C1BAF859400A92AD2 /* AppDelegate.h */, 8D7DCD4D1BAF859400A92AD2 /* AppDelegate.m */, - 8D7DCD4F1BAF859400A92AD2 /* ViewController.h */, - 8D7DCD501BAF859400A92AD2 /* ViewController.m */, + 3D0E5F7C1BB5DA7C0031F61E /* SearchFieldDelegate.h */, + 3D341FD91BB1EC73002D0D89 /* APIManager.h */, + 3D341FDA1BB1EC73002D0D89 /* APIManager.m */, + 3D341FD61BB1EAB9002D0D89 /* ListOfPlacesVC.h */, + 3D341FD71BB1EAB9002D0D89 /* ListOfPlacesVC.m */, + 3D341FDC1BB37847002D0D89 /* LocationObjects.h */, + 3D341FDD1BB37847002D0D89 /* LocationObjects.m */, + 3D0E5F761BB5D40D0031F61E /* SearchVC.h */, + 3D0E5F771BB5D40D0031F61E /* SearchVC.m */, + 3D0E5F791BB5D5F30031F61E /* TableListVC.h */, + 3D0E5F7A1BB5D5F30031F61E /* TableListVC.m */, 8D7DCD521BAF859400A92AD2 /* Main.storyboard */, 8D7DCD551BAF859400A92AD2 /* Assets.xcassets */, 8D7DCD571BAF859400A92AD2 /* LaunchScreen.storyboard */, @@ -110,6 +140,7 @@ TargetAttributes = { 8D7DCD451BAF859400A92AD2 = { CreatedOnToolsVersion = 7.0; + DevelopmentTeam = 3358H79N3F; }; }; }; @@ -149,9 +180,13 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 8D7DCD511BAF859400A92AD2 /* ViewController.m in Sources */, + 3D341FDB1BB1EC73002D0D89 /* APIManager.m in Sources */, 8D7DCD4E1BAF859400A92AD2 /* AppDelegate.m in Sources */, 8D7DCD4B1BAF859400A92AD2 /* main.m in Sources */, + 3D341FDE1BB37847002D0D89 /* LocationObjects.m in Sources */, + 3D0E5F781BB5D40D0031F61E /* SearchVC.m in Sources */, + 3D0E5F7B1BB5D5F30031F61E /* TableListVC.m in Sources */, + 3D341FD81BB1EAB9002D0D89 /* ListOfPlacesVC.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -261,11 +296,14 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; INFOPLIST_FILE = TalkinToTheNet/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.4; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.mikekavouras.TalkinToTheNet; + PRODUCT_BUNDLE_IDENTIFIER = c4q.accesscode.zovfreullia.TalkinToTheNet; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; }; name = Debug; }; @@ -273,11 +311,14 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; INFOPLIST_FILE = TalkinToTheNet/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.4; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.mikekavouras.TalkinToTheNet; + PRODUCT_BUNDLE_IDENTIFIER = c4q.accesscode.zovfreullia.TalkinToTheNet; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; }; name = Release; }; @@ -300,6 +341,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..786476c --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/APIManager.h @@ -0,0 +1,17 @@ +// +// APIManager.h +// 09-19-APILearn +// +// Created by Fatima Zenine Villanueva on 9/20/15. +// Copyright © 2015 apps. All rights reserved. +// + +#import + +@interface APIManager : NSObject + + ++ (void)GETRequestWithURL: (NSURL *)URL + completeHandler: (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..79d9351 --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/APIManager.m @@ -0,0 +1,32 @@ +// +// APIManager.m +// 09-19-APILearn +// +// Created by Fatima Zenine Villanueva on 9/20/15. +// Copyright © 2015 apps. All rights reserved. +// + +#import "APIManager.h" + +@implementation APIManager + ++ (void)GETRequestWithURL: (NSURL *)URL + completeHandler: (void(^)(NSData *data, NSURLResponse *response, NSError *error))completionHandler { + + // creating the request + 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(), ^{ + + //NSLog(@"%@", data); + + completionHandler(data, response, error); + + }); + }]; + + [task resume]; +} + +@end diff --git a/TalkinToTheNet/TalkinToTheNet/Assets.xcassets/Contents.json b/TalkinToTheNet/TalkinToTheNet/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TalkinToTheNet/TalkinToTheNet/Assets.xcassets/close.imageset/Contents.json b/TalkinToTheNet/TalkinToTheNet/Assets.xcassets/close.imageset/Contents.json new file mode 100644 index 0000000..0b53002 --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/Assets.xcassets/close.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "close.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TalkinToTheNet/TalkinToTheNet/Assets.xcassets/close.imageset/close.png b/TalkinToTheNet/TalkinToTheNet/Assets.xcassets/close.imageset/close.png new file mode 100644 index 0000000..75182ed Binary files /dev/null and b/TalkinToTheNet/TalkinToTheNet/Assets.xcassets/close.imageset/close.png differ diff --git a/TalkinToTheNet/TalkinToTheNet/Assets.xcassets/glass.imageset/Contents.json b/TalkinToTheNet/TalkinToTheNet/Assets.xcassets/glass.imageset/Contents.json new file mode 100644 index 0000000..1d58997 --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/Assets.xcassets/glass.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "glass.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TalkinToTheNet/TalkinToTheNet/Assets.xcassets/glass.imageset/glass.png b/TalkinToTheNet/TalkinToTheNet/Assets.xcassets/glass.imageset/glass.png new file mode 100644 index 0000000..1a0c767 Binary files /dev/null and b/TalkinToTheNet/TalkinToTheNet/Assets.xcassets/glass.imageset/glass.png differ diff --git a/TalkinToTheNet/TalkinToTheNet/Assets.xcassets/list.imageset/Contents.json b/TalkinToTheNet/TalkinToTheNet/Assets.xcassets/list.imageset/Contents.json new file mode 100644 index 0000000..de3f3b6 --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/Assets.xcassets/list.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "list.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TalkinToTheNet/TalkinToTheNet/Assets.xcassets/list.imageset/list.png b/TalkinToTheNet/TalkinToTheNet/Assets.xcassets/list.imageset/list.png new file mode 100644 index 0000000..9be873a Binary files /dev/null and b/TalkinToTheNet/TalkinToTheNet/Assets.xcassets/list.imageset/list.png differ diff --git a/TalkinToTheNet/TalkinToTheNet/Base.lproj/LaunchScreen.storyboard b/TalkinToTheNet/TalkinToTheNet/Base.lproj/LaunchScreen.storyboard index 2e721e1..9105557 100644 --- a/TalkinToTheNet/TalkinToTheNet/Base.lproj/LaunchScreen.storyboard +++ b/TalkinToTheNet/TalkinToTheNet/Base.lproj/LaunchScreen.storyboard @@ -1,7 +1,8 @@ - + - + + diff --git a/TalkinToTheNet/TalkinToTheNet/Base.lproj/Main.storyboard b/TalkinToTheNet/TalkinToTheNet/Base.lproj/Main.storyboard index f56d2f3..84eb73f 100644 --- a/TalkinToTheNet/TalkinToTheNet/Base.lproj/Main.storyboard +++ b/TalkinToTheNet/TalkinToTheNet/Base.lproj/Main.storyboard @@ -1,25 +1,310 @@ - + - + + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + diff --git a/TalkinToTheNet/TalkinToTheNet/Info.plist b/TalkinToTheNet/TalkinToTheNet/Info.plist index 6905cc6..8dfa9a2 100644 --- a/TalkinToTheNet/TalkinToTheNet/Info.plist +++ b/TalkinToTheNet/TalkinToTheNet/Info.plist @@ -2,6 +2,15 @@ + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + NSLocationAlwaysUsageDescription + + NSLocationWhenInUseUsageDescription + CFBundleDevelopmentRegion en CFBundleExecutable diff --git a/TalkinToTheNet/TalkinToTheNet/ListOfPlacesVC.h b/TalkinToTheNet/TalkinToTheNet/ListOfPlacesVC.h new file mode 100644 index 0000000..0315ed5 --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/ListOfPlacesVC.h @@ -0,0 +1,14 @@ +// +// ListOfPlacesVC.h +// TalkinToTheNet +// +// Created by Fatima Zenine Villanueva on 9/22/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import +#import +#import "SearchFieldDelegate.h" + +@interface ListOfPlacesVC : UIViewController +@end diff --git a/TalkinToTheNet/TalkinToTheNet/ListOfPlacesVC.m b/TalkinToTheNet/TalkinToTheNet/ListOfPlacesVC.m new file mode 100644 index 0000000..20b476e --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/ListOfPlacesVC.m @@ -0,0 +1,149 @@ +// +// ListOfPlacesVC.m +// TalkinToTheNet +// +// Created by Fatima Zenine Villanueva on 9/22/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import "ListOfPlacesVC.h" +#import "APIManager.h" +#import "LocationObjects.h" +#import +#import +#import "SearchVC.h" +#import "TableListVC.h" + +@interface ListOfPlacesVC () + + + +@property (weak, nonatomic) IBOutlet UITableView *tableView; +@property (weak, nonatomic) IBOutlet UITextField *searchField; +@property (nonatomic, retain) CLLocationManager *locationManager; +@property (weak, nonatomic) IBOutlet MKMapView *yourMapView; +@property (nonatomic) NSMutableArray *searchResults; +@property (nonatomic) NSString *latitude; +@property (nonatomic) NSString *longitude; + +@end + +@implementation ListOfPlacesVC + +#pragma mark - Delegate + +- (void)userHitsGoSearchButton:(NSString *)searchItem{ + [self.yourMapView removeAnnotations:self.yourMapView.annotations]; + NSLog(@"Delegate working: %@", searchItem); + [self makeNewFourSquareRequestWithSearchTerm:searchItem callbackBlock:^{ + [self.tableView reloadData]; + }]; +} + +#pragma mark - Setup + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.yourMapView.delegate = self; + + self.locationManager = [[CLLocationManager alloc] init]; + self.locationManager.delegate = self; + self.locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; + [self.locationManager requestWhenInUseAuthorization]; + [self.locationManager startUpdatingLocation]; +} + +#pragma mark - Map View + +- (IBAction)getLocation:(UIBarButtonItem *)sender { + self.yourMapView.showsUserLocation = YES; +} + + +#pragma mark - FourSquare Request + +- (void)makeNewFourSquareRequestWithSearchTerm: (NSString *)searchTerm + callbackBlock:(void(^)())block { + + + NSString *urlString = [NSString stringWithFormat:@"https://api.foursquare.com/v2/venues/search?client_id=5Y2D3ZEAIKSIXM1ENLUST5SUWU00KZ1PWONSWEPM4VL4MPWY&client_secret=UTBSHJFUEMDSVGLBTOQG4PSP00ZHGIIUUIZJVWHG4Y3O3XK0&v=20130815&ll=%@,%@&query=%@",self.latitude,self.longitude, searchTerm]; + + NSString *encodedstring = [urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; + NSLog(@"%@", encodedstring); + + NSURL *url = [NSURL URLWithString:encodedstring]; + + [APIManager GETRequestWithURL:url completeHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + + if (data !=nil){ + NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; + + NSDictionary *response = [json objectForKey:@"response"]; + NSDictionary *venues = [response objectForKey:@"venues"]; + + self.searchResults = [[NSMutableArray alloc]init]; + + for (NSDictionary *result in venues){ + + NSString *lngString = [[result objectForKey:@"location"] objectForKey:@"lng"]; + NSString *latString = [[result objectForKey:@"location"] objectForKey:@"lat"]; + double lat = [latString doubleValue]; + double lng = [lngString doubleValue]; + + NSString *name = [result objectForKey:@"name"]; + NSString *address = [[result objectForKey:@"location"]objectForKey:@"address"]; + + MKCoordinateRegion region = { {0.0, 0.0} , {0.0, 0.0} }; + region.center.latitude = lat; + region.center.longitude = lng; + region.span.longitudeDelta = 0.01f; + region.span.latitudeDelta = 0.01f; + + [self.yourMapView setRegion:region animated:YES]; + + LocationObjects *obj = [[LocationObjects alloc]init]; + obj.title = name; + obj.subtitle = address; + obj.latitude = self.latitude; + obj.longitude = self.longitude; + obj.coordinate = region.center; + + [self.yourMapView addAnnotation:obj]; + + [self.searchResults addObject:obj]; + + } + + block(); + } + + }]; +} + +- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{ + CLLocation *location = locations.lastObject; + self.longitude = [NSString stringWithFormat:@"%.1f", location.coordinate.longitude]; + self.latitude = [NSString stringWithFormat:@"%.1f",location.coordinate.latitude]; + NSLog(@"latitude: %@ and longitude: %@", self.latitude, self.longitude); + + [self.locationManager stopUpdatingLocation]; +} + + +#pragma mark - Navigation + +- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + if ([[segue identifier] isEqualToString:@"TableViewID"]){ + NSLog(@"Off to the table!"); + TableListVC *vc = segue.destinationViewController; + vc.locationResults = self.searchResults; + } + + else if ([[segue identifier] isEqualToString:@"SearchViewID"]){ + SearchVC *vc = segue.destinationViewController; + vc.delegate = self; + } +} + +@end diff --git a/TalkinToTheNet/TalkinToTheNet/LocationObjects.h b/TalkinToTheNet/TalkinToTheNet/LocationObjects.h new file mode 100644 index 0000000..2c7fa74 --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/LocationObjects.h @@ -0,0 +1,24 @@ +// +// LocationObjects.h +// TalkinToTheNet +// +// Created by Fatima Zenine Villanueva on 9/23/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import +#import + +@interface LocationObjects : NSObject { + NSString *title; + NSString *subtitle; + CLLocationCoordinate2D coordinate; +} + +@property (nonatomic) NSString *latitude; +@property (nonatomic) NSString *longitude; +@property (nonatomic, copy) NSString *title; +@property (nonatomic, copy) NSString *subtitle; +@property (nonatomic) NSString *weather; +@property (nonatomic, assign) CLLocationCoordinate2D coordinate; +@end diff --git a/TalkinToTheNet/TalkinToTheNet/LocationObjects.m b/TalkinToTheNet/TalkinToTheNet/LocationObjects.m new file mode 100644 index 0000000..5ddb1c4 --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/LocationObjects.m @@ -0,0 +1,15 @@ +// +// LocationObjects.m +// TalkinToTheNet +// +// Created by Fatima Zenine Villanueva on 9/23/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import "LocationObjects.h" + +@implementation LocationObjects + +@synthesize title, subtitle, coordinate; + +@end diff --git a/TalkinToTheNet/TalkinToTheNet/SearchFieldDelegate.h b/TalkinToTheNet/TalkinToTheNet/SearchFieldDelegate.h new file mode 100644 index 0000000..2b2e190 --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/SearchFieldDelegate.h @@ -0,0 +1,18 @@ +// +// SearchFieldDelegate.h +// TalkinToTheNet +// +// Created by Fatima Zenine Villanueva on 9/25/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import + +@protocol SearchFieldDelegate + +@required + +- (void)userHitsGoSearchButton:(NSString *)searchItem; + + +@end diff --git a/TalkinToTheNet/TalkinToTheNet/SearchVC.h b/TalkinToTheNet/TalkinToTheNet/SearchVC.h new file mode 100644 index 0000000..c487d17 --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/SearchVC.h @@ -0,0 +1,17 @@ +// +// SearchVC.h +// TalkinToTheNet +// +// Created by Fatima Zenine Villanueva on 9/25/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import +#import "SearchFieldDelegate.h" + +@interface SearchVC : UIViewController + +@property (nonatomic, weak) id delegate; + + +@end diff --git a/TalkinToTheNet/TalkinToTheNet/SearchVC.m b/TalkinToTheNet/TalkinToTheNet/SearchVC.m new file mode 100644 index 0000000..ba88cd5 --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/SearchVC.m @@ -0,0 +1,49 @@ +// +// SearchVC.m +// TalkinToTheNet +// +// Created by Fatima Zenine Villanueva on 9/25/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import "SearchVC.h" + +@interface SearchVC () +@property (weak, nonatomic) IBOutlet UITextField *searchField; + +@end + +@implementation SearchVC + +- (BOOL)textFieldShouldReturn:(UITextField *)textField { + + // dismiss the keyboard + [self.view endEditing:YES]; + + return YES; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view. + + self.searchField.delegate = self; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +- (IBAction)closeScreen:(UIButton *)sender { + [self.navigationController popToRootViewControllerAnimated:YES]; +} + +- (IBAction)goSearchButton:(UIButton *)sender { + [self.navigationController popToRootViewControllerAnimated:YES]; + [self.delegate userHitsGoSearchButton:self.searchField.text]; +} + + + +@end diff --git a/TalkinToTheNet/TalkinToTheNet/TableListVC.h b/TalkinToTheNet/TalkinToTheNet/TableListVC.h new file mode 100644 index 0000000..1f045fa --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/TableListVC.h @@ -0,0 +1,15 @@ +// +// TableListVC.h +// TalkinToTheNet +// +// Created by Fatima Zenine Villanueva on 9/25/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import + +@interface TableListVC : UIViewController + +@property (nonatomic) NSMutableArray *locationResults; + +@end diff --git a/TalkinToTheNet/TalkinToTheNet/TableListVC.m b/TalkinToTheNet/TalkinToTheNet/TableListVC.m new file mode 100644 index 0000000..1a68026 --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/TableListVC.m @@ -0,0 +1,92 @@ +// +// TableListVC.m +// TalkinToTheNet +// +// Created by Fatima Zenine Villanueva on 9/25/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import "TableListVC.h" +#import "LocationObjects.h" +#import "APIManager.h" + +@interface TableListVC () + +@property (weak, nonatomic) IBOutlet UITableView *tableView; + +@end + +@implementation TableListVC + +- (void)viewDidLoad { + [super viewDidLoad]; + self.tableView.delegate = self; + self.tableView.dataSource = self; + + NSLog(@"%@", self.locationResults); + + + for (int i = 0; i < self.locationResults.count; i++) { + LocationObjects *obj = [self.locationResults objectAtIndex:i]; + [self makeNewWeatherRequestWithSearchTerm:obj callbackBlock:^{ + [self.tableView reloadData]; + }]; + } +} + + +- (IBAction)closeButton:(UIButton *)sender { + [self.navigationController popToRootViewControllerAnimated:YES]; +} + +#pragma mark - Table View + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"]; + LocationObjects *post = self.locationResults[indexPath.row]; + cell.textLabel.text = post.title; + cell.detailTextLabel.text = [NSString stringWithFormat:@"Weather: %@", post.weather]; + return cell; +} + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return self.locationResults.count; +} + +#pragma mark - Weather + +- (void)makeNewWeatherRequestWithSearchTerm: (LocationObjects *)obj + callbackBlock:(void(^)())block { + + NSString *urlString = [NSString stringWithFormat:@"http://api.openweathermap.org/data/2.5/weather?lat=%@&lon=%@",obj.latitude, obj.longitude]; + + NSString *encodedstring = [urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; + NSLog(@"%@", encodedstring); + + NSURL *url = [NSURL URLWithString:encodedstring]; + + [APIManager GETRequestWithURL:url completeHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + + if (data !=nil){ + NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; + + NSDictionary *weather = [json objectForKey:@"weather"]; + + for (NSDictionary *result in weather) { + NSString *detailWeather = [result objectForKey:@"description"]; + obj.weather = detailWeather; + } + block(); + } + + }]; + +} + + + +@end diff --git a/TalkinToTheNet/TalkinToTheNet/ViewController.h b/TalkinToTheNet/TalkinToTheNet/ViewController.h deleted file mode 100644 index 8113a85..0000000 --- a/TalkinToTheNet/TalkinToTheNet/ViewController.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// ViewController.h -// TalkinToTheNet -// -// Created by Michael Kavouras on 9/20/15. -// Copyright © 2015 Mike Kavouras. All rights reserved. -// - -#import - -@interface ViewController : UIViewController - - -@end - diff --git a/TalkinToTheNet/TalkinToTheNet/ViewController.m b/TalkinToTheNet/TalkinToTheNet/ViewController.m deleted file mode 100644 index cbefa29..0000000 --- a/TalkinToTheNet/TalkinToTheNet/ViewController.m +++ /dev/null @@ -1,27 +0,0 @@ -// -// ViewController.m -// TalkinToTheNet -// -// Created by Michael Kavouras on 9/20/15. -// Copyright © 2015 Mike Kavouras. All rights reserved. -// - -#import "ViewController.h" - -@interface ViewController () - -@end - -@implementation ViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. -} - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -@end