From b6621a603ae7c398b5ddea552c675b00c21b4274 Mon Sep 17 00:00:00 2001 From: Bereket Ghebremedhin Date: Fri, 25 Sep 2015 16:39:47 -0400 Subject: [PATCH 01/27] error with saving the phrase fro m the cell --- .../TalkinToTheNet.xcodeproj/project.pbxproj | 25 ++- TalkinToTheNet/TalkinToTheNet/API Manager.h | 18 ++ TalkinToTheNet/TalkinToTheNet/API Manager.m | 32 ++++ .../Base.lproj/LaunchScreen.storyboard | 5 +- .../TalkinToTheNet/Base.lproj/Main.storyboard | 170 ++++++++++++++++-- .../DetailLocationViewController.h | 20 +++ .../DetailLocationViewController.m | 39 ++++ .../ListOfLocationsTableViewController.h | 13 ++ .../ListOfLocationsTableViewController.m | 118 ++++++++++++ .../TalkinToTheNet/ViewController.m | 27 --- 10 files changed, 422 insertions(+), 45 deletions(-) create mode 100644 TalkinToTheNet/TalkinToTheNet/API Manager.h create mode 100644 TalkinToTheNet/TalkinToTheNet/API Manager.m create mode 100644 TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.h create mode 100644 TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m create mode 100644 TalkinToTheNet/TalkinToTheNet/ListOfLocationsTableViewController.h create mode 100644 TalkinToTheNet/TalkinToTheNet/ListOfLocationsTableViewController.m delete mode 100644 TalkinToTheNet/TalkinToTheNet/ViewController.m diff --git a/TalkinToTheNet/TalkinToTheNet.xcodeproj/project.pbxproj b/TalkinToTheNet/TalkinToTheNet.xcodeproj/project.pbxproj index ee35a70..9c14485 100644 --- a/TalkinToTheNet/TalkinToTheNet.xcodeproj/project.pbxproj +++ b/TalkinToTheNet/TalkinToTheNet.xcodeproj/project.pbxproj @@ -9,10 +9,12 @@ /* Begin PBXBuildFile section */ 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 */; }; + AB6E6E5D1BB4B10300756BD8 /* ListOfLocationsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AB6E6E5C1BB4B10300756BD8 /* ListOfLocationsTableViewController.m */; settings = {ASSET_TAGS = (); }; }; + AB6E6E601BB4B12200756BD8 /* DetailLocationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AB6E6E5F1BB4B12200756BD8 /* DetailLocationViewController.m */; settings = {ASSET_TAGS = (); }; }; + AB6E6E631BB4BA7000756BD8 /* API Manager.m in Sources */ = {isa = PBXBuildFile; fileRef = AB6E6E621BB4BA7000756BD8 /* API Manager.m */; settings = {ASSET_TAGS = (); }; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -20,12 +22,16 @@ 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 = ""; }; 8D7DCD5A1BAF859400A92AD2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + AB6E6E5B1BB4B10300756BD8 /* ListOfLocationsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ListOfLocationsTableViewController.h; sourceTree = ""; }; + AB6E6E5C1BB4B10300756BD8 /* ListOfLocationsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ListOfLocationsTableViewController.m; sourceTree = ""; }; + AB6E6E5E1BB4B12200756BD8 /* DetailLocationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DetailLocationViewController.h; sourceTree = ""; }; + AB6E6E5F1BB4B12200756BD8 /* DetailLocationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DetailLocationViewController.m; sourceTree = ""; }; + AB6E6E611BB4BA7000756BD8 /* API Manager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "API Manager.h"; sourceTree = ""; }; + AB6E6E621BB4BA7000756BD8 /* API Manager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "API Manager.m"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -60,8 +66,12 @@ children = ( 8D7DCD4C1BAF859400A92AD2 /* AppDelegate.h */, 8D7DCD4D1BAF859400A92AD2 /* AppDelegate.m */, - 8D7DCD4F1BAF859400A92AD2 /* ViewController.h */, - 8D7DCD501BAF859400A92AD2 /* ViewController.m */, + AB6E6E611BB4BA7000756BD8 /* API Manager.h */, + AB6E6E621BB4BA7000756BD8 /* API Manager.m */, + AB6E6E5B1BB4B10300756BD8 /* ListOfLocationsTableViewController.h */, + AB6E6E5C1BB4B10300756BD8 /* ListOfLocationsTableViewController.m */, + AB6E6E5E1BB4B12200756BD8 /* DetailLocationViewController.h */, + AB6E6E5F1BB4B12200756BD8 /* DetailLocationViewController.m */, 8D7DCD521BAF859400A92AD2 /* Main.storyboard */, 8D7DCD551BAF859400A92AD2 /* Assets.xcassets */, 8D7DCD571BAF859400A92AD2 /* LaunchScreen.storyboard */, @@ -149,7 +159,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 8D7DCD511BAF859400A92AD2 /* ViewController.m in Sources */, + AB6E6E631BB4BA7000756BD8 /* API Manager.m in Sources */, + AB6E6E601BB4B12200756BD8 /* DetailLocationViewController.m in Sources */, + AB6E6E5D1BB4B10300756BD8 /* ListOfLocationsTableViewController.m in Sources */, 8D7DCD4E1BAF859400A92AD2 /* AppDelegate.m in Sources */, 8D7DCD4B1BAF859400A92AD2 /* main.m in Sources */, ); @@ -300,6 +312,7 @@ 8D7DCD5F1BAF859400A92AD2 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/TalkinToTheNet/TalkinToTheNet/API Manager.h b/TalkinToTheNet/TalkinToTheNet/API Manager.h new file mode 100644 index 0000000..2e906c6 --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/API Manager.h @@ -0,0 +1,18 @@ +// +// API Manager.h +// TalkinToTheNet +// +// Created by Bereket on 9/24/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import + +@interface API_Manager : NSObject + ++ (void)GETRequestWithURL:(NSURL *)URL + completionHandler:(void(^)(NSData *data, NSURLResponse *response, NSError *error))completionBlock; + + + +@end diff --git a/TalkinToTheNet/TalkinToTheNet/API Manager.m b/TalkinToTheNet/TalkinToTheNet/API Manager.m new file mode 100644 index 0000000..7cbb3eb --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/API Manager.m @@ -0,0 +1,32 @@ +// +// API Manager.m +// TalkinToTheNet +// +// Created by Bereket on 9/24/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import "API Manager.h" + +@implementation API_Manager + + + ++ (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 diff --git a/TalkinToTheNet/TalkinToTheNet/Base.lproj/LaunchScreen.storyboard b/TalkinToTheNet/TalkinToTheNet/Base.lproj/LaunchScreen.storyboard index 2e721e1..aa08113 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..5af9fa4 100644 --- a/TalkinToTheNet/TalkinToTheNet/Base.lproj/Main.storyboard +++ b/TalkinToTheNet/TalkinToTheNet/Base.lproj/Main.storyboard @@ -1,25 +1,175 @@ - + - + + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + diff --git a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.h b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.h new file mode 100644 index 0000000..552748e --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.h @@ -0,0 +1,20 @@ +// +// DetailLocationViewController.h +// TalkinToTheNet +// +// Created by Bereket on 9/24/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import + +@interface DetailLocationViewController : UIViewController + + +@property (nonatomic) NSString* queryPhrase; + + +@property (strong, nonatomic) IBOutlet UITextView *fourSquareAddressTextView; + + +@end diff --git a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m new file mode 100644 index 0000000..c17e32e --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m @@ -0,0 +1,39 @@ +// +// DetailLocationViewController.m +// TalkinToTheNet +// +// Created by Bereket on 9/24/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import "DetailLocationViewController.h" + +@interface DetailLocationViewController () + +@end + +@implementation DetailLocationViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + //NSLog(@"%@", self.queryPhrase); + // Do any additional setup after loading the view. +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end diff --git a/TalkinToTheNet/TalkinToTheNet/ListOfLocationsTableViewController.h b/TalkinToTheNet/TalkinToTheNet/ListOfLocationsTableViewController.h new file mode 100644 index 0000000..f18bf14 --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/ListOfLocationsTableViewController.h @@ -0,0 +1,13 @@ +// +// ListOfLocationsTableViewController.h +// TalkinToTheNet +// +// Created by Bereket on 9/24/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import + +@interface ListOfLocationsTableViewController : UITableViewController +@property (nonatomic) NSString* selectedQuery; +@end diff --git a/TalkinToTheNet/TalkinToTheNet/ListOfLocationsTableViewController.m b/TalkinToTheNet/TalkinToTheNet/ListOfLocationsTableViewController.m new file mode 100644 index 0000000..3f974e4 --- /dev/null +++ b/TalkinToTheNet/TalkinToTheNet/ListOfLocationsTableViewController.m @@ -0,0 +1,118 @@ +// +// ListOfLocationsTableViewController.m +// TalkinToTheNet +// +// Created by Bereket on 9/24/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import "ListOfLocationsTableViewController.h" +#import "DetailLocationViewController.h" + +@interface ListOfLocationsTableViewController () + +@property (nonatomic) NSArray* ListOfLocationsArray; + +@end + +@implementation ListOfLocationsTableViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + self.ListOfLocationsArray = @[@"Bronx Alehouse", @"An Beal Bocht", @"Wave Hill"]; + + // Uncomment the following line to preserve selection between presentations. + // self.clearsSelectionOnViewWillAppear = NO; + + // Uncomment the following line to display an Edit button in the navigation bar for this view controller. + // self.navigationItem.rightBarButtonItem = self.editButtonItem; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return self.ListOfLocationsArray.count; +} + + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CellIdentifier" forIndexPath:indexPath]; + + cell.textLabel.text = self.ListOfLocationsArray[indexPath.row]; + + + + return cell; +} + + +-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{ + + UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath]; + self.selectedQuery = selectedCell.detailTextLabel.text; + + NSLog(@"%@", self.selectedQuery); +} +/* +// Override to support conditional editing of the table view. +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the specified item to be editable. + return YES; +} +*/ + +/* +// Override to support editing the table view. +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { + if (editingStyle == UITableViewCellEditingStyleDelete) { + // Delete the row from the data source + [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; + } else if (editingStyle == UITableViewCellEditingStyleInsert) { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view + } +} +*/ + +/* +// Override to support rearranging the table view. +- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { +} +*/ + +/* +// Override to support conditional rearranging of the table view. +- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the item to be re-orderable. + return YES; +} +*/ + + +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + + + + DetailLocationViewController* viewController = segue.destinationViewController; + + + + + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} + + +@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 From 5a77cdb57c29ff49abc5616dc99fd8b3eef924b2 Mon Sep 17 00:00:00 2001 From: Bereket Ghebremedhin Date: Fri, 25 Sep 2015 18:29:14 -0400 Subject: [PATCH 02/27] data in JSONObjectWithData is nill --- .../DetailLocationViewController.h | 3 ++ .../DetailLocationViewController.m | 47 +++++++++++++++++-- .../ListOfLocationsTableViewController.m | 17 ++++--- 3 files changed, 56 insertions(+), 11 deletions(-) diff --git a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.h b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.h index 552748e..0531f4e 100644 --- a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.h +++ b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.h @@ -7,12 +7,15 @@ // #import +#import "API Manager.h" @interface DetailLocationViewController : UIViewController @property (nonatomic) NSString* queryPhrase; +@property (nonatomic) NSURL * url; +-(void)fetchFourSquareData; @property (strong, nonatomic) IBOutlet UITextView *fourSquareAddressTextView; diff --git a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m index c17e32e..cd898be 100644 --- a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m +++ b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m @@ -17,15 +17,54 @@ @implementation DetailLocationViewController - (void)viewDidLoad { [super viewDidLoad]; - //NSLog(@"%@", self.queryPhrase); + NSLog(@"%@", self.queryPhrase); + + + + if ([self.queryPhrase isEqual: @"Bronx AleHouse"] ) + { + self.url = [NSURL URLWithString:@"https://api.foursquare.com/v2/venues/search?ll=40.884786,-73.899595"]; + + + } + else if([self.queryPhrase isEqual: @"An Beal Bocht"]){ + + self.url = [NSURL URLWithString:@""]; + + } + else if([self.queryPhrase isEqual: @"Wave Hill"]){ + + self.url = [NSURL URLWithString:@""]; + + } + else { + NSLog(@"dude you broke my code :("); + } + + + [self fetchFourSquareData]; // Do any additional setup after loading the view. } -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. + + +-(void)fetchFourSquareData{ + + [API_Manager GETRequestWithURL:self.url completionHandler:^(NSData* data, NSURLResponse* response, NSError* error){ + + NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; + + NSLog(@"%@",json); + }]; + + } + + + + + /* #pragma mark - Navigation diff --git a/TalkinToTheNet/TalkinToTheNet/ListOfLocationsTableViewController.m b/TalkinToTheNet/TalkinToTheNet/ListOfLocationsTableViewController.m index 3f974e4..d89d29c 100644 --- a/TalkinToTheNet/TalkinToTheNet/ListOfLocationsTableViewController.m +++ b/TalkinToTheNet/TalkinToTheNet/ListOfLocationsTableViewController.m @@ -56,13 +56,14 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } --(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{ - - UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath]; - self.selectedQuery = selectedCell.detailTextLabel.text; - - NSLog(@"%@", self.selectedQuery); -} +//-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{ +// +// +// UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath]; +// self.selectedQuery = selectedCell.detailTextLabel.text; +// +// NSLog(@"%@", self.selectedQuery); +//} /* // Override to support conditional editing of the table view. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { @@ -105,7 +106,9 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + NSIndexPath* indexPath = [self.tableView indexPathForSelectedRow]; DetailLocationViewController* viewController = segue.destinationViewController; + viewController.queryPhrase = self.ListOfLocationsArray[indexPath.row]; From 2866a732531cfc9354fe98824aefb880d00c1914 Mon Sep 17 00:00:00 2001 From: Bereket Ghebremedhin Date: Fri, 25 Sep 2015 19:08:27 -0400 Subject: [PATCH 03/27] not getting JSON still --- .../TalkinToTheNet/DetailLocationViewController.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m index cd898be..39563ea 100644 --- a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m +++ b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m @@ -23,9 +23,13 @@ - (void)viewDidLoad { if ([self.queryPhrase isEqual: @"Bronx AleHouse"] ) { - self.url = [NSURL URLWithString:@"https://api.foursquare.com/v2/venues/search?ll=40.884786,-73.899595"]; - + NSString* urlString= @"https://api.foursquare.com/v2/venues/search?client_id=DQU1A2YJWRSRRIP1OM1LHRVRH4RLVBDCD11OTNGOQ2QRDNPH&client_secret=V2DXHM04GZDA1FKRGDLIPLEGZ3D0BP25GNN4XB4L1GSY3E2B&ll=40.884786,-73.899595"; + + NSString* encodedString = [urlString stringByAddingPercentEscapesUsingEncoding:[NSCharacterSet URLQueryAllowedCharacterSet]]; + + + self.url = [NSURL URLWithString:encodedString]; } else if([self.queryPhrase isEqual: @"An Beal Bocht"]){ From 4b8c137c45074e4800f6d2292ff7aa94813e45b3 Mon Sep 17 00:00:00 2001 From: Bereket Ghebremedhin Date: Fri, 25 Sep 2015 20:19:01 -0400 Subject: [PATCH 04/27] Fixed one problem but still no JSON --- TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m index 39563ea..95590c5 100644 --- a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m +++ b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m @@ -23,7 +23,7 @@ - (void)viewDidLoad { if ([self.queryPhrase isEqual: @"Bronx AleHouse"] ) { - NSString* urlString= @"https://api.foursquare.com/v2/venues/search?client_id=DQU1A2YJWRSRRIP1OM1LHRVRH4RLVBDCD11OTNGOQ2QRDNPH&client_secret=V2DXHM04GZDA1FKRGDLIPLEGZ3D0BP25GNN4XB4L1GSY3E2B&ll=40.884786,-73.899595"; + NSString* urlString= @"https://api.foursquare.com/v2/venues/search?client_id=DQU1A2YJWRSRRIP1OM1LHRVRH4RLVBDCD11OTNGOQ2QRDNPH&client_secret=V2DXHM04GZDA1FKRGDLIPLEGZ3D0BP25GNN4XB4L1GSY3E2B&v=20152509&v=20130815&ll=40.884786,-73.899595"; NSString* encodedString = [urlString stringByAddingPercentEscapesUsingEncoding:[NSCharacterSet URLQueryAllowedCharacterSet]]; From 95bd26daa75835c33a29893f782cdc8d5c5a8b8f Mon Sep 17 00:00:00 2001 From: Bereket Ghebremedhin Date: Fri, 25 Sep 2015 20:28:32 -0400 Subject: [PATCH 05/27] fixed JSON --- .../DetailLocationViewController.m | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m index 95590c5..07162c2 100644 --- a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m +++ b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m @@ -9,11 +9,9 @@ #import "DetailLocationViewController.h" @interface DetailLocationViewController () - +@property (nonatomic) NSString *yourChoice; @end - @implementation DetailLocationViewController - - (void)viewDidLoad { [super viewDidLoad]; @@ -23,35 +21,41 @@ - (void)viewDidLoad { if ([self.queryPhrase isEqual: @"Bronx AleHouse"] ) { - NSString* urlString= @"https://api.foursquare.com/v2/venues/search?client_id=DQU1A2YJWRSRRIP1OM1LHRVRH4RLVBDCD11OTNGOQ2QRDNPH&client_secret=V2DXHM04GZDA1FKRGDLIPLEGZ3D0BP25GNN4XB4L1GSY3E2B&v=20152509&v=20130815&ll=40.884786,-73.899595"; - - NSString* encodedString = [urlString stringByAddingPercentEscapesUsingEncoding:[NSCharacterSet URLQueryAllowedCharacterSet]]; + self.yourChoice = @"bronxalehouse"; - - self.url = [NSURL URLWithString:encodedString]; } else if([self.queryPhrase isEqual: @"An Beal Bocht"]){ - self.url = [NSURL URLWithString:@""]; + self.yourChoice = @""; //..... // do the same thing as above + } else if([self.queryPhrase isEqual: @"Wave Hill"]){ - self.url = [NSURL URLWithString:@""]; - - } - else { - NSLog(@"dude you broke my code :("); + self.yourChoice = @""; } + + NSString *urlString = [NSString stringWithFormat:@"https://api.foursquare.com/v2/venues/search?client_id=DQU1A2YJWRSRRIP1OM1LHRVRH4RLVBDCD11OTNGOQ2QRDNPH&client_secret=V2DXHM04GZDA1FKRGDLIPLEGZ3D0BP25GNN4XB4L1GSY3E2B&v=20130815&ll=40.7,-74&query=%@",self.yourChoice]; + + NSString* encodedString = [urlString stringByAddingPercentEscapesUsingEncoding:[NSCharacterSet URLQueryAllowedCharacterSet]]; + + self.url = [NSURL URLWithString:encodedString]; + + + + // + // else { + // NSLog(@"dude you broke my code :("); + // } + // + [self fetchFourSquareData]; // Do any additional setup after loading the view. } - - -(void)fetchFourSquareData{ [API_Manager GETRequestWithURL:self.url completionHandler:^(NSData* data, NSURLResponse* response, NSError* error){ From 81961682352a8670abff9ee21b6ee1c246f258ea Mon Sep 17 00:00:00 2001 From: Bereket Ghebremedhin Date: Fri, 25 Sep 2015 20:38:59 -0400 Subject: [PATCH 06/27] Wrong JSON data --- TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m index 07162c2..7eaf151 100644 --- a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m +++ b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m @@ -38,7 +38,7 @@ - (void)viewDidLoad { - NSString *urlString = [NSString stringWithFormat:@"https://api.foursquare.com/v2/venues/search?client_id=DQU1A2YJWRSRRIP1OM1LHRVRH4RLVBDCD11OTNGOQ2QRDNPH&client_secret=V2DXHM04GZDA1FKRGDLIPLEGZ3D0BP25GNN4XB4L1GSY3E2B&v=20130815&ll=40.7,-74&query=%@",self.yourChoice]; + NSString *urlString = [NSString stringWithFormat:@"https://api.foursquare.com/v2/venues/search?client_id=DQU1A2YJWRSRRIP1OM1LHRVRH4RLVBDCD11OTNGOQ2QRDNPH&client_secret=V2DXHM04GZDA1FKRGDLIPLEGZ3D0BP25GNN4XB4L1GSY3E2B&v=20130815&ll=40.884786,-73.899595&query=%@",self.yourChoice]; NSString* encodedString = [urlString stringByAddingPercentEscapesUsingEncoding:[NSCharacterSet URLQueryAllowedCharacterSet]]; From 850a363f7010d4107eaa20bf73f33da5fe5d64dc Mon Sep 17 00:00:00 2001 From: Bereket Ghebremedhin Date: Fri, 25 Sep 2015 21:18:14 -0400 Subject: [PATCH 07/27] seems like im getting the right JSON --- .../TalkinToTheNet/DetailLocationViewController.m | 12 ++++++------ .../ListOfLocationsTableViewController.m | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m index 7eaf151..eff34c1 100644 --- a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m +++ b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m @@ -19,26 +19,26 @@ - (void)viewDidLoad { - if ([self.queryPhrase isEqual: @"Bronx AleHouse"] ) + if ([self.queryPhrase isEqual: @"Waldorf Astoria"] ) { - self.yourChoice = @"bronxalehouse"; + self.yourChoice = @"waldorfastoria"; } - else if([self.queryPhrase isEqual: @"An Beal Bocht"]){ + else if([self.queryPhrase isEqual: @"Rockefeller Center"]){ - self.yourChoice = @""; //..... // do the same thing as above + self.yourChoice = @"rockefellercenter"; //..... // do the same thing as above } else if([self.queryPhrase isEqual: @"Wave Hill"]){ - self.yourChoice = @""; + self.yourChoice = @"waveHill"; } + NSString *urlString = [NSString stringWithFormat:@"https://api.foursquare.com/v2/venues/search?client_id=DQU1A2YJWRSRRIP1OM1LHRVRH4RLVBDCD11OTNGOQ2QRDNPH&client_secret=V2DXHM04GZDA1FKRGDLIPLEGZ3D0BP25GNN4XB4L1GSY3E2B&v=20130815&ll=40.7,-74&query=%@",self.yourChoice]; - NSString *urlString = [NSString stringWithFormat:@"https://api.foursquare.com/v2/venues/search?client_id=DQU1A2YJWRSRRIP1OM1LHRVRH4RLVBDCD11OTNGOQ2QRDNPH&client_secret=V2DXHM04GZDA1FKRGDLIPLEGZ3D0BP25GNN4XB4L1GSY3E2B&v=20130815&ll=40.884786,-73.899595&query=%@",self.yourChoice]; NSString* encodedString = [urlString stringByAddingPercentEscapesUsingEncoding:[NSCharacterSet URLQueryAllowedCharacterSet]]; diff --git a/TalkinToTheNet/TalkinToTheNet/ListOfLocationsTableViewController.m b/TalkinToTheNet/TalkinToTheNet/ListOfLocationsTableViewController.m index d89d29c..ffc99ec 100644 --- a/TalkinToTheNet/TalkinToTheNet/ListOfLocationsTableViewController.m +++ b/TalkinToTheNet/TalkinToTheNet/ListOfLocationsTableViewController.m @@ -19,7 +19,7 @@ @implementation ListOfLocationsTableViewController - (void)viewDidLoad { [super viewDidLoad]; - self.ListOfLocationsArray = @[@"Bronx Alehouse", @"An Beal Bocht", @"Wave Hill"]; + self.ListOfLocationsArray = @[@"Waldorf Astoria", @"Rockefeller Center", @"Wave Hill"]; // Uncomment the following line to preserve selection between presentations. // self.clearsSelectionOnViewWillAppear = NO; From 300200385ae53c545133825828744da3c3773bdc Mon Sep 17 00:00:00 2001 From: Bereket Ghebremedhin Date: Fri, 25 Sep 2015 21:52:54 -0400 Subject: [PATCH 08/27] now only getting 1 JSON for WaveHill which is good but then it throws an error --- .../TalkinToTheNet/DetailLocationViewController.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m index eff34c1..106b75d 100644 --- a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m +++ b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m @@ -9,7 +9,10 @@ #import "DetailLocationViewController.h" @interface DetailLocationViewController () + @property (nonatomic) NSString *yourChoice; +@property NSString* locationAddress; + @end @implementation DetailLocationViewController - (void)viewDidLoad { @@ -33,7 +36,7 @@ - (void)viewDidLoad { } else if([self.queryPhrase isEqual: @"Wave Hill"]){ - self.yourChoice = @"waveHill"; + self.yourChoice = @"wavehill"; } @@ -63,6 +66,10 @@ -(void)fetchFourSquareData{ NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; NSLog(@"%@",json); + + self.locationAddress = [NSString stringWithFormat:[json objectForKey:@"formattedAddress"]]; + + self.fourSquareAddressTextView.text = self.locationAddress; }]; From 6168baa148ca4f487b2d02b3d813e165b506b450 Mon Sep 17 00:00:00 2001 From: Bereket Ghebremedhin Date: Fri, 25 Sep 2015 21:57:28 -0400 Subject: [PATCH 09/27] figured out lines 70-72 are throwing the error but not sure why --- .../TalkinToTheNet/DetailLocationViewController.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m index 106b75d..d5d8efa 100644 --- a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m +++ b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m @@ -67,9 +67,9 @@ -(void)fetchFourSquareData{ NSLog(@"%@",json); - self.locationAddress = [NSString stringWithFormat:[json objectForKey:@"formattedAddress"]]; - - self.fourSquareAddressTextView.text = self.locationAddress; +// self.locationAddress = [NSString stringWithFormat:[json objectForKey:@"formattedAddress"]]; +// +// self.fourSquareAddressTextView.text = self.locationAddress; }]; From 8295bf539000199ed5dfa9fa07d788ec81f622e8 Mon Sep 17 00:00:00 2001 From: Bereket Ghebremedhin Date: Fri, 25 Sep 2015 22:05:51 -0400 Subject: [PATCH 10/27] figured out why I have multiple JSONS --- TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m index d5d8efa..c14e434 100644 --- a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m +++ b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m @@ -24,13 +24,13 @@ - (void)viewDidLoad { if ([self.queryPhrase isEqual: @"Waldorf Astoria"] ) { - self.yourChoice = @"waldorfastoria"; + self.yourChoice = @"waldorfastoriahotel"; } else if([self.queryPhrase isEqual: @"Rockefeller Center"]){ - self.yourChoice = @"rockefellercenter"; //..... // do the same thing as above + self.yourChoice = @"RockefellerCenter"; //..... // do the same thing as above } From b0e455356171af42bbb480a6832e8ef8b5961f0b Mon Sep 17 00:00:00 2001 From: Bereket Ghebremedhin Date: Fri, 25 Sep 2015 22:53:32 -0400 Subject: [PATCH 11/27] Changed Rockefeller to Madame Tussauds, I needed more specificty in the search for Rockefeller but after maybe close to two dozen attempts. I found myself either getting now results, multiple with the right one or multiple without the right one. Would like to go back in when I build v2 and figure out how to resolve that. I fixed it with the other two but 30rock has proven to be a challenge. --- TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m | 4 ++-- .../TalkinToTheNet/ListOfLocationsTableViewController.m | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m index c14e434..14a09f2 100644 --- a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m +++ b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m @@ -28,9 +28,9 @@ - (void)viewDidLoad { } - else if([self.queryPhrase isEqual: @"Rockefeller Center"]){ + else if([self.queryPhrase isEqual: @"Madame Tussauds"]){ - self.yourChoice = @"RockefellerCenter"; //..... // do the same thing as above + self.yourChoice = @"madametussauds"; //..... // do the same thing as above } diff --git a/TalkinToTheNet/TalkinToTheNet/ListOfLocationsTableViewController.m b/TalkinToTheNet/TalkinToTheNet/ListOfLocationsTableViewController.m index ffc99ec..be72a4c 100644 --- a/TalkinToTheNet/TalkinToTheNet/ListOfLocationsTableViewController.m +++ b/TalkinToTheNet/TalkinToTheNet/ListOfLocationsTableViewController.m @@ -19,7 +19,7 @@ @implementation ListOfLocationsTableViewController - (void)viewDidLoad { [super viewDidLoad]; - self.ListOfLocationsArray = @[@"Waldorf Astoria", @"Rockefeller Center", @"Wave Hill"]; + self.ListOfLocationsArray = @[@"Waldorf Astoria", @"Madame Tussauds", @"Wave Hill"]; // Uncomment the following line to preserve selection between presentations. // self.clearsSelectionOnViewWillAppear = NO; From 28a9b4c74e631094875bd8644f097e44a0741ae3 Mon Sep 17 00:00:00 2001 From: Bereket Ghebremedhin Date: Fri, 25 Sep 2015 23:44:36 -0400 Subject: [PATCH 12/27] some changes --- .../DetailLocationViewController.m | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m index 14a09f2..348fa56 100644 --- a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m +++ b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m @@ -65,13 +65,25 @@ -(void)fetchFourSquareData{ NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; - NSLog(@"%@",json); + // NSLog(@"%@",json); + + NSArray* results = [[json objectForKey:@"results"]objectForKey:@"venues"]; + + for (NSDictionary* result in results){ + NSString* address = [result objectForKey:@"formattedAddress"]; + self.locationAddress = address; + NSLog(@"%@", address); + + } + + // self.locationAddress = [NSString stringWithFormat:[json objectForKey:@"formattedAddress"]]; // // self.fourSquareAddressTextView.text = self.locationAddress; }]; - + self.fourSquareAddressTextView.text= self.locationAddress; + NSLog(@"%@",self.locationAddress); } From 729f489c60a30243289dd095aaaf5ad97fe5f94e Mon Sep 17 00:00:00 2001 From: Bereket Ghebremedhin Date: Sat, 26 Sep 2015 00:04:48 -0400 Subject: [PATCH 13/27] using instagram instead --- .../TalkinToTheNet/Base.lproj/Main.storyboard | 27 ++++++------------- .../DetailLocationViewController.h | 2 +- .../DetailLocationViewController.m | 2 +- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/TalkinToTheNet/TalkinToTheNet/Base.lproj/Main.storyboard b/TalkinToTheNet/TalkinToTheNet/Base.lproj/Main.storyboard index 5af9fa4..715e60c 100644 --- a/TalkinToTheNet/TalkinToTheNet/Base.lproj/Main.storyboard +++ b/TalkinToTheNet/TalkinToTheNet/Base.lproj/Main.storyboard @@ -53,20 +53,6 @@ - - - - - - - - - - - - - - @@ -89,6 +75,7 @@ + @@ -125,17 +112,19 @@ + + + + + - - + - - - + diff --git a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.h b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.h index 0531f4e..1efbcbf 100644 --- a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.h +++ b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.h @@ -9,7 +9,7 @@ #import #import "API Manager.h" -@interface DetailLocationViewController : UIViewController +@interface DetailLocationViewController : UIViewController @property (nonatomic) NSString* queryPhrase; diff --git a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m index 348fa56..24c104b 100644 --- a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m +++ b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m @@ -67,7 +67,7 @@ -(void)fetchFourSquareData{ // NSLog(@"%@",json); - NSArray* results = [[json objectForKey:@"results"]objectForKey:@"venues"]; + NSArray* results = [[json objectForKey:@"response"]objectForKey:@"venues"]; for (NSDictionary* result in results){ NSString* address = [result objectForKey:@"formattedAddress"]; From 01141f688de5b60adf034cdc7a91a502f01f4f85 Mon Sep 17 00:00:00 2001 From: Bereket Ghebremedhin Date: Sat, 26 Sep 2015 00:32:42 -0400 Subject: [PATCH 14/27] address stored --- .../DetailLocationViewController.m | 69 +++++++++---------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m index 24c104b..624fea5 100644 --- a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m +++ b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m @@ -5,34 +5,33 @@ // Created by Bereket on 9/24/15. // Copyright © 2015 Mike Kavouras. All rights reserved. // - #import "DetailLocationViewController.h" +#import "API Manager.h" @interface DetailLocationViewController () @property (nonatomic) NSString *yourChoice; + @property NSString* locationAddress; @end + @implementation DetailLocationViewController + - (void)viewDidLoad { [super viewDidLoad]; - NSLog(@"%@", self.queryPhrase); + NSLog(@"self.queryPhrase %@", self.queryPhrase); if ([self.queryPhrase isEqual: @"Waldorf Astoria"] ) { self.yourChoice = @"waldorfastoriahotel"; - - } else if([self.queryPhrase isEqual: @"Madame Tussauds"]){ self.yourChoice = @"madametussauds"; //..... // do the same thing as above - - } else if([self.queryPhrase isEqual: @"Wave Hill"]){ @@ -43,11 +42,14 @@ - (void)viewDidLoad { NSString *urlString = [NSString stringWithFormat:@"https://api.foursquare.com/v2/venues/search?client_id=DQU1A2YJWRSRRIP1OM1LHRVRH4RLVBDCD11OTNGOQ2QRDNPH&client_secret=V2DXHM04GZDA1FKRGDLIPLEGZ3D0BP25GNN4XB4L1GSY3E2B&v=20130815&ll=40.7,-74&query=%@",self.yourChoice]; - NSString* encodedString = [urlString stringByAddingPercentEscapesUsingEncoding:[NSCharacterSet URLQueryAllowedCharacterSet]]; + //encoded url + NSString *encodedString = [urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; - self.url = [NSURL URLWithString:encodedString]; + self.url = [NSURL URLWithString:encodedString]; + NSLog(@"self.url %@", self.url); + // // else { @@ -58,48 +60,43 @@ - (void)viewDidLoad { [self fetchFourSquareData]; // Do any additional setup after loading the view. } - -(void)fetchFourSquareData{ - + NSLog(@"called this method"); [API_Manager GETRequestWithURL:self.url completionHandler:^(NSData* data, NSURLResponse* response, NSError* error){ - NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; + NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; + + NSArray *results = [[json objectForKey:@"response"] objectForKey:@"venues"]; - // NSLog(@"%@",json); - NSArray* results = [[json objectForKey:@"response"]objectForKey:@"venues"]; for (NSDictionary* result in results){ - NSString* address = [result objectForKey:@"formattedAddress"]; + + NSString* address = [[result objectForKey:@"location"] objectForKey:@"formattedAddress"]; + + + self.locationAddress = address; - NSLog(@"%@", address); - + NSLog(@"The address is %@", address); + } -// self.locationAddress = [NSString stringWithFormat:[json objectForKey:@"formattedAddress"]]; -// -// self.fourSquareAddressTextView.text = self.locationAddress; + // self.locationAddress = [NSString stringWithFormat:[json objectForKey:@"formattedAddress"]]; + // + // self.fourSquareAddressTextView.text = self.locationAddress; }]; self.fourSquareAddressTextView.text= self.locationAddress; - NSLog(@"%@",self.locationAddress); - + // NSLog(@"self.locationAddress %@",self.locationAddress); } - - - - - - /* -#pragma mark - Navigation - -// In a storyboard-based application, you will often want to do a little preparation before navigation -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - // Get the new view controller using [segue destinationViewController]. - // Pass the selected object to the new view controller. -} -*/ - + #pragma mark - Navigation + // In a storyboard-based application, you will often want to do a little preparation before navigation + - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. + } + */ @end + From 94b60042c49d3073c8df8e126d14fc7db48cf8ea Mon Sep 17 00:00:00 2001 From: Bereket Ghebremedhin Date: Sat, 26 Sep 2015 00:44:58 -0400 Subject: [PATCH 15/27] Label change broke --- .../TalkinToTheNet/Base.lproj/Main.storyboard | 25 +++++++++++-------- .../DetailLocationViewController.h | 2 +- .../DetailLocationViewController.m | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/TalkinToTheNet/TalkinToTheNet/Base.lproj/Main.storyboard b/TalkinToTheNet/TalkinToTheNet/Base.lproj/Main.storyboard index 715e60c..aab0a94 100644 --- a/TalkinToTheNet/TalkinToTheNet/Base.lproj/Main.storyboard +++ b/TalkinToTheNet/TalkinToTheNet/Base.lproj/Main.storyboard @@ -65,22 +65,22 @@ - - - - - + - - - + + + - - + @@ -114,6 +114,9 @@ + + + @@ -137,7 +140,7 @@ - + diff --git a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.h b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.h index 1efbcbf..903f972 100644 --- a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.h +++ b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.h @@ -17,7 +17,7 @@ -(void)fetchFourSquareData; -@property (strong, nonatomic) IBOutlet UITextView *fourSquareAddressTextView; +@property (strong, nonatomic) IBOutlet UILabel *fourSquareAddressTextLabel; @end diff --git a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m index 624fea5..5a32c89 100644 --- a/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m +++ b/TalkinToTheNet/TalkinToTheNet/DetailLocationViewController.m @@ -87,7 +87,7 @@ -(void)fetchFourSquareData{ // // self.fourSquareAddressTextView.text = self.locationAddress; }]; - self.fourSquareAddressTextView.text= self.locationAddress; + self.fourSquareAddressTextLabel.text= self.locationAddress; // NSLog(@"self.locationAddress %@",self.locationAddress); } /* From 897705f2a84871374ad5fb86f2eeaf6dcf917197 Mon Sep 17 00:00:00 2001 From: Bereket Ghebremedhin Date: Sat, 26 Sep 2015 01:36:28 -0400 Subject: [PATCH 16/27] think the label situation will be figured out soon. When its in the API Manager I can see the LAbel, but not the text. Suspecting its an issue of order of code --- .../TalkinToTheNet/Base.lproj/Main.storyboard | 2 +- .../DetailLocationViewController.m | 32 +++++++++++++------ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/TalkinToTheNet/TalkinToTheNet/Base.lproj/Main.storyboard b/TalkinToTheNet/TalkinToTheNet/Base.lproj/Main.storyboard index aab0a94..9266a88 100644 --- a/TalkinToTheNet/TalkinToTheNet/Base.lproj/Main.storyboard +++ b/TalkinToTheNet/TalkinToTheNet/Base.lproj/Main.storyboard @@ -65,7 +65,7 @@ -