Skip to content
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 .DS_Store
Binary file not shown.
Binary file added FixaDaApp/.DS_Store
Binary file not shown.
4 changes: 4 additions & 0 deletions FixaDaApp/FixaDaApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,11 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = FixaDaApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.mikekavouras.FixaDaApp;
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = 1;
};
name = Debug;
};
Expand All @@ -364,9 +366,11 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = FixaDaApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.mikekavouras.FixaDaApp;
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = 1;
};
name = Release;
};
Expand Down
42 changes: 32 additions & 10 deletions FixaDaApp/FixaDaApp/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9059" systemVersion="15A284" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
</dependencies>
<scenes>
<!--View Controller-->
Expand All @@ -19,43 +19,65 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<mapView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" mapType="standard" showsUserLocation="YES" translatesAutoresizingMaskIntoConstraints="NO" id="QhC-Y4-i8h">
<rect key="frame" x="0.0" y="0.0" width="600" height="100"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="400"/>
<animations/>
<constraints>
<constraint firstAttribute="height" constant="200" id="S1n-L7-tix"/>
<constraint firstAttribute="height" constant="400" id="jpS-bK-y0B"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="S1n-L7-tix"/>
<exclude reference="jpS-bK-y0B"/>
</mask>
</variation>
</mapView>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="BMq-V3-f2f">
<rect key="frame" x="0.0" y="100" width="600" height="500"/>
<rect key="frame" x="0.0" y="400" width="600" height="200"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" textLabel="4Wd-lS-p0j" style="IBUITableViewCellStyleDefault" id="5cm-8d-a5a">
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="BeepBoopCellIdentifier" textLabel="4Wd-lS-p0j" style="IBUITableViewCellStyleDefault" id="5cm-8d-a5a">
<rect key="frame" x="0.0" y="28" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="5cm-8d-a5a" id="cpW-0e-B2H">
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="4Wd-lS-p0j">
<rect key="frame" x="15" y="0.0" width="570" height="43.5"/>
<rect key="frame" x="15" y="0.0" width="570" height="43"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<animations/>
</tableViewCellContentView>
<animations/>
</tableViewCell>
</prototypes>
</tableView>
</subviews>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="BMq-V3-f2f" firstAttribute="top" secondItem="QhC-Y4-i8h" secondAttribute="bottom" id="829-uy-XA8"/>
<constraint firstItem="QhC-Y4-i8h" firstAttribute="height" secondItem="BMq-V3-f2f" secondAttribute="height" multiplier="0.2" id="DcL-ga-xdl"/>
<constraint firstAttribute="trailing" secondItem="BMq-V3-f2f" secondAttribute="trailing" id="Ddx-sp-gAW"/>
<constraint firstItem="QhC-Y4-i8h" firstAttribute="width" secondItem="BMq-V3-f2f" secondAttribute="height" multiplier="1.5:1" id="NIu-qe-uGD"/>
<constraint firstItem="BMq-V3-f2f" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="PGd-F5-XwA"/>
<constraint firstItem="QhC-Y4-i8h" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="PS4-bX-CJK"/>
<constraint firstAttribute="trailing" secondItem="QhC-Y4-i8h" secondAttribute="trailing" id="mbZ-IW-xGJ"/>
<constraint firstItem="QhC-Y4-i8h" firstAttribute="top" secondItem="8bC-Xf-vdC" secondAttribute="top" id="sq5-GT-TWp"/>
<constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="BMq-V3-f2f" secondAttribute="bottom" id="vLg-lx-GXH"/>
<constraint firstItem="BMq-V3-f2f" firstAttribute="width" secondItem="QhC-Y4-i8h" secondAttribute="height" multiplier="1.5:1" id="wPw-pU-NhG"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="NIu-qe-uGD"/>
</mask>
</variation>
</view>
<connections>
<outlet property="mapView" destination="QhC-Y4-i8h" id="SMQ-g7-itJ"/>
Expand Down
2 changes: 1 addition & 1 deletion FixaDaApp/FixaDaApp/FoursquareAPIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@

+ (void)findSomething:(NSString *)query
atLocation:(CLLocation *)location
completion:(void(^)(NSArray *data))completion;
completion:(void(^)(NSDictionary *data))completion;

@end
12 changes: 9 additions & 3 deletions FixaDaApp/FixaDaApp/FoursquareAPIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "FoursquareAPIManager.h"
#import <AFNetworking/AFNetworking.h>
#import <CoreLocation/CoreLocation.h>

#define kFoursquareAPIClientID @"GWKJBVWFYBJQ02T3TRBB4VBL24AIO4TCMJCGIQ5ADKVKJXGP"
#define kFoursquareAPIClientSecret @"2WMEZCDQNKNB5XAE5F4BY1VHBK1HITYRU1JEVCOAD2QRLXDJ"
Expand All @@ -27,18 +28,23 @@ @implementation FoursquareAPIManager

+ (void)findSomething:(NSString *)query
atLocation:(CLLocation *)location
completion:(void(^)(NSArray *data))completion
completion:(void(^)(NSDictionary *data))completion
{
NSString *baseURL = @"https://api.foursquare.com/v2/venues/search";
NSString *url = [NSString stringWithFormat:@"%@?client_id=%@&client_secret=%@&v=20160215&ll=%f,%f&query=%@", baseURL, kFoursquareAPIClientID, kFoursquareAPIClientSecret, location.coordinate.latitude, location.coordinate.longitude, query];
NSString *url = [NSString stringWithFormat:@"%@?client_id=%@&client_secret=%@&v=20160215&ll=%f,%f&query=%@", baseURL, kFoursquareAPIClientID, kFoursquareAPIClientSecret,location.coordinate.latitude,location.coordinate.longitude, query];

AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] init];

[manager GET:url
parameters:nil
progress:nil
success:^(NSURLSessionTask *task, id responseObject)
{
//NSLog(@"JSON: %@",responseObject);
NSDictionary *venues = responseObject[@"response"][@"venues"];
//NSLog(@"JSON: %@",venues);

completion(venues);

} failure:^(NSURLSessionTask *operation, NSError *error)
{
Expand Down
5 changes: 5 additions & 0 deletions FixaDaApp/FixaDaApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Show you the places!</string>
<key>CFBundleDevelopmentRegion</key>
Expand Down
42 changes: 34 additions & 8 deletions FixaDaApp/FixaDaApp/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "ViewController.h"
#import <MapKit/MapKit.h>
#import "FoursquareAPIManager.h"
#import <CoreLocation/CoreLocation.h>

@interface ViewController ()
<
Expand All @@ -24,7 +25,7 @@ @interface ViewController ()

@property (nonatomic, assign) BOOL foundPlaces;

@property (nonatomic) NSArray *venues;
@property (nonatomic) NSDictionary *venues;

@end

Expand All @@ -36,18 +37,30 @@ - (void)viewDidLoad {
self.tableView.delegate = self;
self.tableView.dataSource = self;

self.venues = [[NSDictionary alloc]init];

self.mapView.delegate = self;

self.locationManager = [[CLLocationManager alloc] init];
self.mapView.showsUserLocation = YES;

[self.locationManager requestWhenInUseAuthorization];

//CLLocationCoordinate2D locationCoords = CLLocationCoordinate2DMake(self.locationManager.location.coordinate.latitude, self.locationManager.location.coordinate.longitude);

CLLocation *myLocation = [[CLLocation alloc]initWithLatitude:self.locationManager.location.coordinate.latitude longitude:self.locationManager.location.coordinate.longitude];

[self fetchVenuesAtLocation:myLocation];


}

- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}


# pragma mark - Table view datasource
#pragma mark - Table view datasource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
Expand All @@ -56,16 +69,24 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 0;
return self.venues.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BeepBoopCellIdentifier"];

NSDictionary *venue = self.venues[indexPath.row];
NSString *name = venue[@"name"];
NSMutableArray *venueArray = [[NSMutableArray alloc]init];
//
for (NSDictionary *venue in self.venues) {
[venueArray addObject:[venue objectForKey:@"name"]];
}

// NSDictionary *venueDict = [venueArray objectAtIndex:indexPath.row];
NSString *name = venueArray[indexPath.row];
cell.textLabel.text = name;
//NSString *name = venue[@"name"];
// cell.textLabel.text = nameArray[indexPath.row];

return cell;
}
Expand Down Expand Up @@ -96,9 +117,13 @@ - (void)fetchVenuesAtLocation:(CLLocation *)location
__weak typeof(self) weakSelf = self;
[FoursquareAPIManager findSomething:@"music"
atLocation:location
completion:^(NSArray *data){
completion:^(NSDictionary *data){

self.venues = data;

NSLog(@"Called");
NSLog(@"JSONdata:%@",data);

weakSelf.venues = data;
[weakSelf.tableView reloadData];
[weakSelf showPins];

Expand All @@ -114,6 +139,7 @@ - (void)showPins
double lng = [venue[@"location"][@"lng"] doubleValue];

MKPointAnnotation *point = [[MKPointAnnotation alloc] init];
point.title = venue[@"name"]; //BONUS POINTS MIKE????
point.coordinate = CLLocationCoordinate2DMake(lat, lng);
[self.mapView addAnnotation:point];
}
Expand Down