Skip to content

Commit

Permalink
Code cleanup in the iOS Example app...no functional changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
cnoon committed Jul 24, 2015
1 parent e0dd9e8 commit e0aa058
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 71 deletions.
2 changes: 0 additions & 2 deletions Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele

return false
}

}

25 changes: 14 additions & 11 deletions Example/DetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import UIKit
import Alamofire
import UIKit

class DetailViewController: UITableViewController {
enum Sections: Int {
Expand All @@ -44,22 +44,22 @@ class DetailViewController: UITableViewController {
var body: String?
var elapsedTime: NSTimeInterval?
var segueIdentifier: String?


// MARK: View Lifecycle

override func awakeFromNib() {
super.awakeFromNib()
self.refreshControl?.addTarget(self, action: "refresh", forControlEvents: .ValueChanged)

}

// MARK: - UIViewController

override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)

self.refresh()
}

// MARK: - IBAction
// MARK: IBActions

@IBAction func refresh() {
if self.request == nil {
Expand All @@ -69,7 +69,7 @@ class DetailViewController: UITableViewController {
self.refreshControl?.beginRefreshing()

let start = CACurrentMediaTime()
self.request?.responseString { (request, response, body, error) in
self.request?.responseString { request, response, body, error in
let end = CACurrentMediaTime()
self.elapsedTime = end - start

Expand Down Expand Up @@ -116,9 +116,11 @@ class DetailViewController: UITableViewController {

return ""
}
}
// MARK: UITableViewDataSource
// MARK: - UITableViewDataSource
extension DetailViewController: UITableViewDataSource {
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch Sections(rawValue: section)! {
case .Headers:
Expand Down Expand Up @@ -150,14 +152,16 @@ class DetailViewController: UITableViewController {
return cell
}
}
}
// MARK: UITableViewDelegate
// MARK: - UITableViewDelegate
extension DetailViewController: UITableViewDelegate {
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 2
}
override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String {
override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
if self.tableView(tableView, numberOfRowsInSection: section) == 0 {
return ""
}
Expand All @@ -179,7 +183,7 @@ class DetailViewController: UITableViewController {
}
}
override func tableView(tableView: UITableView, titleForFooterInSection section: Int) -> String {
override func tableView(tableView: UITableView, titleForFooterInSection section: Int) -> String? {
if Sections(rawValue: section) == .Body, let elapsedTime = self.elapsedTime {
let numberFormatter = NSNumberFormatter()
numberFormatter.numberStyle = .DecimalStyle
Expand All @@ -190,4 +194,3 @@ class DetailViewController: UITableViewController {
return ""
}
}

44 changes: 0 additions & 44 deletions Example/HTTPBin.swift

This file was deleted.

8 changes: 4 additions & 4 deletions Example/MasterViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import UIKit
import Alamofire
import UIKit

class MasterViewController: UITableViewController {

Expand All @@ -30,14 +30,14 @@ class MasterViewController: UITableViewController {
var detailViewController: DetailViewController? = nil
var objects = NSMutableArray()

// MARK: - View Lifecycle

override func awakeFromNib() {
super.awakeFromNib()

self.navigationItem.titleView = self.titleImageView
}

// MARK: - UIViewController

override func viewDidLoad() {
super.viewDidLoad()

Expand All @@ -52,7 +52,7 @@ class MasterViewController: UITableViewController {
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let detailViewController = segue.destinationViewController.topViewController as? DetailViewController {
func requestForSegue(segue: UIStoryboardSegue) -> Request? {
switch segue.identifier as String! {
switch segue.identifier! {
case "GET":
detailViewController.segueIdentifier = "GET"
return Alamofire.request(.GET, "http://httpbin.org/get")
Expand Down
46 changes: 36 additions & 10 deletions iOS Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,23 @@
F8111E1419A951050040E7D1 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F8111E1319A951050040E7D1 /* Images.xcassets */; };
F818D0E419CA8CFA006034B1 /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8111E5419A95D7C0040E7D1 /* Alamofire.framework */; };
F818D0E619CA8D25006034B1 /* Alamofire.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = F8111E5419A95D7C0040E7D1 /* Alamofire.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
F8E6024019CB3C0700A3E7F1 /* HTTPBin.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8E6023F19CB3C0700A3E7F1 /* HTTPBin.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
4C6B5FD61B61F692009A2891 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F8111E4E19A95D7C0040E7D1 /* Alamofire.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 4DD67C0B1A5C55C900ED2280;
remoteInfo = "Alamofire OSX";
};
4C6B5FD81B61F692009A2891 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F8111E4E19A95D7C0040E7D1 /* Alamofire.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = F829C6B21A7A94F100A2CD59;
remoteInfo = "Alamofire OSX Tests";
};
F8111E5319A95D7C0040E7D1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F8111E4E19A95D7C0040E7D1 /* Alamofire.xcodeproj */;
Expand Down Expand Up @@ -64,7 +77,6 @@
F8111E1119A951050040E7D1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
F8111E1319A951050040E7D1 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
F8111E4E19A95D7C0040E7D1 /* Alamofire.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = Alamofire.xcodeproj; sourceTree = "<group>"; };
F8E6023F19CB3C0700A3E7F1 /* HTTPBin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HTTPBin.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -100,11 +112,8 @@
isa = PBXGroup;
children = (
F8111E0A19A951050040E7D1 /* AppDelegate.swift */,
F8111E0C19A951050040E7D1 /* MasterViewController.swift */,
F8111E0E19A951050040E7D1 /* DetailViewController.swift */,
F8E6023F19CB3C0700A3E7F1 /* HTTPBin.swift */,
F8111E1019A951050040E7D1 /* Main.storyboard */,
F8111E1319A951050040E7D1 /* Images.xcassets */,
F8111E0C19A951050040E7D1 /* MasterViewController.swift */,
F8111E0819A951050040E7D1 /* Supporting Files */,
);
name = Source;
Expand All @@ -115,6 +124,8 @@
isa = PBXGroup;
children = (
F8111E0919A951050040E7D1 /* Info.plist */,
F8111E1019A951050040E7D1 /* Main.storyboard */,
F8111E1319A951050040E7D1 /* Images.xcassets */,
);
name = "Supporting Files";
sourceTree = "<group>";
Expand All @@ -123,7 +134,9 @@
isa = PBXGroup;
children = (
F8111E5419A95D7C0040E7D1 /* Alamofire.framework */,
F8111E5619A95D7C0040E7D1 /* AlamofireTests.xctest */,
4C6B5FD71B61F692009A2891 /* Alamofire.framework */,
F8111E5619A95D7C0040E7D1 /* Alamofire iOS Tests.xctest */,
4C6B5FD91B61F692009A2891 /* Alamofire OSX Tests.xctest */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -189,17 +202,31 @@
/* End PBXProject section */

/* Begin PBXReferenceProxy section */
4C6B5FD71B61F692009A2891 /* Alamofire.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = Alamofire.framework;
remoteRef = 4C6B5FD61B61F692009A2891 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
4C6B5FD91B61F692009A2891 /* Alamofire OSX Tests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = "Alamofire OSX Tests.xctest";
remoteRef = 4C6B5FD81B61F692009A2891 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
F8111E5419A95D7C0040E7D1 /* Alamofire.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = Alamofire.framework;
remoteRef = F8111E5319A95D7C0040E7D1 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
F8111E5619A95D7C0040E7D1 /* AlamofireTests.xctest */ = {
F8111E5619A95D7C0040E7D1 /* Alamofire iOS Tests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = AlamofireTests.xctest;
path = "Alamofire iOS Tests.xctest";
remoteRef = F8111E5519A95D7C0040E7D1 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
Expand All @@ -223,7 +250,6 @@
buildActionMask = 2147483647;
files = (
F8111E0F19A951050040E7D1 /* DetailViewController.swift in Sources */,
F8E6024019CB3C0700A3E7F1 /* HTTPBin.swift in Sources */,
F8111E0D19A951050040E7D1 /* MasterViewController.swift in Sources */,
F8111E0B19A951050040E7D1 /* AppDelegate.swift in Sources */,
);
Expand Down

0 comments on commit e0aa058

Please sign in to comment.