Skip to content

Commit

Permalink
finish video tutorial #1
Browse files Browse the repository at this point in the history
  • Loading branch information
gprasant committed Nov 2, 2015
1 parent 35c5bc8 commit 33f73d2
Show file tree
Hide file tree
Showing 8 changed files with 239 additions and 4 deletions.
18 changes: 18 additions & 0 deletions Yelp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
/* Begin PBXBuildFile section */
11F304F81BDC02C1000ED8EF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 11F304F71BDC02C1000ED8EF /* LaunchScreen.storyboard */; };
11F304FF1BDC476D000ED8EF /* YelpBusiness.m in Sources */ = {isa = PBXBuildFile; fileRef = 11F304FE1BDC476D000ED8EF /* YelpBusiness.m */; };
1285727F1BE6D53400D34D38 /* BusinessCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 1285727D1BE6D53400D34D38 /* BusinessCell.m */; };
128572801BE6D53400D34D38 /* BusinessCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1285727E1BE6D53400D34D38 /* BusinessCell.xib */; };
420474F618DC299500E88E07 /* YelpClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 420474F518DC299500E88E07 /* YelpClient.m */; };
420474FB18DC2B2100E88E07 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 420474F918DC2B2100E88E07 /* MainViewController.m */; };
420474FC18DC2B2100E88E07 /* MainViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 420474FA18DC2B2100E88E07 /* MainViewController.xib */; };
Expand Down Expand Up @@ -41,6 +43,9 @@
11F304F71BDC02C1000ED8EF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
11F304FD1BDC476D000ED8EF /* YelpBusiness.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YelpBusiness.h; sourceTree = "<group>"; };
11F304FE1BDC476D000ED8EF /* YelpBusiness.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YelpBusiness.m; sourceTree = "<group>"; };
1285727C1BE6D53400D34D38 /* BusinessCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BusinessCell.h; sourceTree = "<group>"; };
1285727D1BE6D53400D34D38 /* BusinessCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BusinessCell.m; sourceTree = "<group>"; };
1285727E1BE6D53400D34D38 /* BusinessCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = BusinessCell.xib; sourceTree = "<group>"; };
420474F418DC299500E88E07 /* YelpClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YelpClient.h; sourceTree = "<group>"; };
420474F518DC299500E88E07 /* YelpClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YelpClient.m; sourceTree = "<group>"; };
420474F818DC2B2100E88E07 /* MainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -101,6 +106,16 @@
name = Models;
sourceTree = "<group>";
};
1285727B1BE6D51300D34D38 /* View */ = {
isa = PBXGroup;
children = (
1285727C1BE6D53400D34D38 /* BusinessCell.h */,
1285727D1BE6D53400D34D38 /* BusinessCell.m */,
1285727E1BE6D53400D34D38 /* BusinessCell.xib */,
);
name = View;
sourceTree = "<group>";
};
420474F318DC297600E88E07 /* API */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -157,6 +172,7 @@
children = (
11F304F91BDC20F3000ED8EF /* Models */,
420474F318DC297600E88E07 /* API */,
1285727B1BE6D51300D34D38 /* View */,
420474F718DC2A9200E88E07 /* View Controllers */,
42FD6C5918DC286B000BF2B9 /* AppDelegate.h */,
42FD6C5A18DC286B000BF2B9 /* AppDelegate.m */,
Expand Down Expand Up @@ -283,6 +299,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
128572801BE6D53400D34D38 /* BusinessCell.xib in Resources */,
42FD6C5518DC286B000BF2B9 /* InfoPlist.strings in Resources */,
11F304F81BDC02C1000ED8EF /* LaunchScreen.storyboard in Resources */,
420474FC18DC2B2100E88E07 /* MainViewController.xib in Resources */,
Expand Down Expand Up @@ -358,6 +375,7 @@
420474F618DC299500E88E07 /* YelpClient.m in Sources */,
420474FB18DC2B2100E88E07 /* MainViewController.m in Sources */,
11F304FF1BDC476D000ED8EF /* YelpBusiness.m in Sources */,
1285727F1BE6D53400D34D38 /* BusinessCell.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
16 changes: 16 additions & 0 deletions Yelp/BusinessCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// BusinessCell.h
// Yelp
//
// Created by Prasanth Guruprasad on 11/1/15.
// Copyright © 2015 codepath. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "YelpBusiness.h"

@interface BusinessCell : UITableViewCell

@property (strong, nonatomic) YelpBusiness *business;

@end
49 changes: 49 additions & 0 deletions Yelp/BusinessCell.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// BusinessCell.m
// Yelp
//
// Created by Prasanth Guruprasad on 11/1/15.
// Copyright © 2015 codepath. All rights reserved.
//

#import "BusinessCell.h"
#import "YelpBusiness.h"
#import "UIImageView+AFNetworking.h"

@interface BusinessCell ()
@property (weak, nonatomic) IBOutlet UIImageView *thumbImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *distanceLabel;
@property (weak, nonatomic) IBOutlet UILabel *ratingsLabel;
@property (weak, nonatomic) IBOutlet UIImageView *ratingsImageView;
@property (weak, nonatomic) IBOutlet UILabel *addressLabel;
@property (weak, nonatomic) IBOutlet UILabel *categoriesLabel;

@end

@implementation BusinessCell

- (void)awakeFromNib {
// Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];

// Configure the view for the selected state
}

- (void)setBusiness:(YelpBusiness *)business {
_business = business;

[self.thumbImageView setImageWithURL: self.business.imageUrl];
self.nameLabel.text = self.business.name;
[self.ratingsImageView setImageWithURL: self.business.ratingImageUrl];
self.distanceLabel.text = self.business.distance;

self.ratingsLabel.text = [NSString stringWithFormat:@"%@ Reviews", [self.business.reviewCount stringValue]];
self.addressLabel.text = self.business.address;
self.categoriesLabel.text = self.business.categories;
}

@end
112 changes: 112 additions & 0 deletions Yelp/BusinessCell.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9059" systemVersion="15A284" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="87" id="KGk-i7-Jjw" customClass="BusinessCell">
<rect key="frame" x="0.0" y="0.0" width="353" height="87"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="353" height="86.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="dqV-Nm-nHJ">
<rect key="frame" x="8" y="8" width="70" height="70"/>
<animations/>
<constraints>
<constraint firstAttribute="width" constant="70" id="3On-gE-rSf"/>
<constraint firstAttribute="height" constant="70" id="Bzg-f1-N1s"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="1. Grand Pu Bah" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iio-4s-A1F">
<rect key="frame" x="86" y="8" width="95" height="14.5"/>
<animations/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="12"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="469 Reviews" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MnB-Kq-9Uo">
<rect key="frame" x="178" y="30" width="62" height="12"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="10"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Thai, Seafood, Salad" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="261-JV-y3Q">
<rect key="frame" x="86" y="66" width="99.5" height="12"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="10"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="88 Division St, Mission Bay" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uGp-Rb-2Tn">
<rect key="frame" x="86" y="51" width="139.5" height="12"/>
<animations/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="10"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="tVm-Da-ZwH">
<rect key="frame" x="86" y="27" width="84" height="17"/>
<animations/>
<constraints>
<constraint firstAttribute="width" constant="84" id="3os-M4-34d"/>
<constraint firstAttribute="height" constant="17" id="VYT-mO-CnR"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0.07 mi" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZHy-Vk-wXz">
<rect key="frame" x="309" y="10" width="35.5" height="12"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="10"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="$$" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UfM-gC-dk6">
<rect key="frame" x="331" y="30" width="13.5" height="12"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="10"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<animations/>
<constraints>
<constraint firstItem="MnB-Kq-9Uo" firstAttribute="centerY" secondItem="tVm-Da-ZwH" secondAttribute="centerY" id="6sI-sz-LOe"/>
<constraint firstItem="uGp-Rb-2Tn" firstAttribute="leading" secondItem="dqV-Nm-nHJ" secondAttribute="trailing" constant="8" id="7YI-qu-0gQ"/>
<constraint firstItem="261-JV-y3Q" firstAttribute="top" secondItem="uGp-Rb-2Tn" secondAttribute="bottom" constant="3" id="9JN-Al-8N9"/>
<constraint firstItem="261-JV-y3Q" firstAttribute="leading" secondItem="dqV-Nm-nHJ" secondAttribute="trailing" constant="8" id="9Po-rG-fRJ"/>
<constraint firstItem="UfM-gC-dk6" firstAttribute="top" secondItem="ZHy-Vk-wXz" secondAttribute="bottom" constant="8" id="A4Y-cK-sxw"/>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="dqV-Nm-nHJ" secondAttribute="bottom" constant="8" id="Agw-UD-Sdo"/>
<constraint firstItem="dqV-Nm-nHJ" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="8" id="CE1-Jq-a7y"/>
<constraint firstItem="ZHy-Vk-wXz" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="iio-4s-A1F" secondAttribute="trailing" constant="8" id="E0i-Mk-8YK"/>
<constraint firstItem="iio-4s-A1F" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="8" id="K9p-7F-ruC"/>
<constraint firstAttribute="trailing" secondItem="ZHy-Vk-wXz" secondAttribute="trailing" constant="8.5" id="LB6-wX-ARu"/>
<constraint firstItem="dqV-Nm-nHJ" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="8" id="azO-Uc-udg"/>
<constraint firstItem="uGp-Rb-2Tn" firstAttribute="top" secondItem="tVm-Da-ZwH" secondAttribute="bottom" constant="7" id="cPz-jr-7z4"/>
<constraint firstItem="tVm-Da-ZwH" firstAttribute="leading" secondItem="dqV-Nm-nHJ" secondAttribute="trailing" constant="8" id="kuN-b7-aGd"/>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="261-JV-y3Q" secondAttribute="bottom" constant="8" id="lCc-Nf-mul"/>
<constraint firstItem="iio-4s-A1F" firstAttribute="leading" secondItem="dqV-Nm-nHJ" secondAttribute="trailing" constant="8" id="rdN-iM-Aih"/>
<constraint firstAttribute="trailing" secondItem="UfM-gC-dk6" secondAttribute="trailing" constant="8.5" id="ro1-zh-U4e"/>
<constraint firstItem="tVm-Da-ZwH" firstAttribute="top" secondItem="iio-4s-A1F" secondAttribute="bottom" constant="4.5" id="s3b-8E-QWu"/>
<constraint firstItem="ZHy-Vk-wXz" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="10" id="vNu-GI-EgH"/>
<constraint firstItem="MnB-Kq-9Uo" firstAttribute="leading" secondItem="tVm-Da-ZwH" secondAttribute="trailing" constant="8" id="xYB-AH-Siv"/>
</constraints>
</tableViewCellContentView>
<animations/>
<connections>
<outlet property="addressLabel" destination="uGp-Rb-2Tn" id="8YG-hP-Ort"/>
<outlet property="categoriesLabel" destination="261-JV-y3Q" id="PUx-5b-8DK"/>
<outlet property="distanceLabel" destination="ZHy-Vk-wXz" id="JqG-ey-Xbm"/>
<outlet property="nameLabel" destination="iio-4s-A1F" id="Z9h-JD-BC7"/>
<outlet property="ratingsImageView" destination="tVm-Da-ZwH" id="9hX-JS-BbD"/>
<outlet property="ratingsLabel" destination="MnB-Kq-9Uo" id="apH-RC-vYs"/>
<outlet property="thumbImageView" destination="dqV-Nm-nHJ" id="2Pu-3K-iGm"/>
</connections>
<point key="canvasLocation" x="276.5" y="264.5"/>
</tableViewCell>
</objects>
</document>
1 change: 1 addition & 0 deletions Yelp/MainViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
#import <UIKit/UIKit.h>

@interface MainViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end
26 changes: 24 additions & 2 deletions Yelp/MainViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,51 @@

#import "MainViewController.h"
#import "YelpBusiness.h"
#import "Businesscell.h"

@interface MainViewController ()
@interface MainViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong) NSArray *businesses;

@end

@implementation MainViewController

- (void)viewDidLoad {
[super viewDidLoad];

[YelpBusiness searchWithTerm:@"Restaurants"
sortMode:YelpSortModeBestMatched
categories:@[@"burgers"]
deals:NO
completion:^(NSArray *businesses, NSError *error) {
self.businesses = businesses;
[self.tableView reloadData];
for (YelpBusiness *business in businesses) {
NSLog(@"%@", business);
}
}];
self.tableView.dataSource = self;
self.tableView.delegate = self;

[self.tableView registerNib:[UINib nibWithNibName:@"BusinessCell" bundle:nil]forCellReuseIdentifier:@"BusinessCell"];
self.tableView.rowHeight = UITableViewAutomaticDimension;
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}

-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(@"Row Count : %lu", self.businesses.count);
return self.businesses.count;
}

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

cell.business = self.businesses[indexPath.row];

return cell;
}

@end
Loading

0 comments on commit 33f73d2

Please sign in to comment.