Skip to content

Commit

Permalink
#swift3 converted to Swift 3 and xCode 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Daltron committed Oct 1, 2016
1 parent 10bd4b7 commit 26568d9
Show file tree
Hide file tree
Showing 201 changed files with 13,935 additions and 10,302 deletions.
8 changes: 4 additions & 4 deletions BigBoard.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = "BigBoard"
s.version = "1.0.1"
s.version = "1.0.2"
s.summary = "An Elegant Financial Markets Library Written in Swift"

# This description is used to generate tags and improve search results.
Expand All @@ -30,9 +30,9 @@ BigBoard is an elegant financial markets library for iOS written in Swift. Under
s.source_files = 'Pod/Classes/**/*'

s.platform = :ios
s.ios.deployment_target = '8.3'
s.ios.deployment_target = '9.0'

s.dependency 'AlamofireObjectMapper', '~> 3.0'
s.dependency 'AlamofireObjectMapper', '~> 4.0'
s.dependency 'Timepiece'
s.dependency 'AlamofireImage', '~> 2.0'
s.dependency 'AlamofireImage', '~> 3.0'
end
409 changes: 212 additions & 197 deletions Example/BigBoard.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -52,6 +52,16 @@
ReferencedContainer = "container:BigBoard.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5CC0FD221D9F4C7200D7660B"
BuildableName = "BigBoardTests.xctest"
BlueprintName = "BigBoardTests"
ReferencedContainer = "container:BigBoard.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
Expand Down
16 changes: 8 additions & 8 deletions Example/BigBoard/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,38 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

let navigationController = UINavigationController(rootViewController: ExampleViewController())
navigationController.navigationBar.barTintColor = UIColor.flatGreenColorDark()
navigationController.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName : UIColor.whiteColor()]
navigationController.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white]

window = UIWindow(frame: UIScreen.mainScreen().bounds)
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = navigationController
window?.makeKeyAndVisible()
return true
}

func applicationWillResignActive(application: UIApplication) {
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication) {
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(application: UIApplication) {
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(application: UIApplication) {
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(application: UIApplication) {
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

Expand Down
6 changes: 3 additions & 3 deletions Example/BigBoard/ExampleAddStockModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ class ExampleAddStockModel: NSObject {
return searchResultStocks.count
}

func searchResultStockAtIndex(index:Int) -> BigBoardSearchResultStock {
func searchResultStockAtIndex(_ index:Int) -> BigBoardSearchResultStock {
return searchResultStocks[index]
}

func fetchStocksForSearchTerm(searchTerm:String, success:(() -> Void), failure:(BigBoardError) -> Void) {
BigBoard.stocksContainingSearchTerm(searchTerm: searchTerm, success: { (stocks:[BigBoardSearchResultStock]) in
func fetchStocksForSearchTerm(_ searchTerm:String, success:@escaping (() -> Void), failure:@escaping (BigBoardError) -> Void) {
_ = BigBoard.stocksContainingSearchTerm(searchTerm: searchTerm, success: { (stocks:[BigBoardSearchResultStock]) in
self.searchResultStocks = stocks
success()
}, failure: failure)
Expand Down
58 changes: 29 additions & 29 deletions Example/BigBoard/ExampleAddStockView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import ChameleonFramework

protocol ExampleAddStockViewDelegate : class {
func numberOfSearchResultStocks() -> Int
func searchResultStockAtIndex(index:Int) -> BigBoardSearchResultStock
func searchTermChanged(searchTerm searchTerm:String)
func stockResultSelectedAtIndex(index:Int)
func searchResultStockAtIndex(_ index:Int) -> BigBoardSearchResultStock
func searchTermChanged(searchTerm:String)
func stockResultSelectedAtIndex(_ index:Int)
}

class ExampleAddStockView: UIView, UITableViewDataSource, UITableViewDelegate {
Expand All @@ -24,42 +24,42 @@ class ExampleAddStockView: UIView, UITableViewDataSource, UITableViewDelegate {
var stocksTableView:UITableView!

init(delegate:ExampleAddStockViewDelegate) {
super.init(frame: CGRectZero)
super.init(frame: CGRect.zero)
self.delegate = delegate
self.backgroundColor = UIColor.whiteColor()
self.backgroundColor = UIColor.white

let searchBarView = UIView()
addSubview(searchBarView)

searchTextField = UITextField()
searchTextField.borderStyle = .RoundedRect
searchTextField.textAlignment = .Center
searchTextField.borderStyle = .roundedRect
searchTextField.textAlignment = .center
searchTextField.placeholder = "Search:"
searchTextField.addTarget(self, action: #selector(searchTermChanged), forControlEvents: .AllEditingEvents)
searchTextField.addTarget(self, action: #selector(searchTermChanged), for: .allEditingEvents)
searchBarView.addSubview(searchTextField)

stocksTableView = UITableView(frame: CGRectZero, style: .Plain)
stocksTableView = UITableView(frame: CGRect.zero, style: .plain)
stocksTableView.dataSource = self
stocksTableView.delegate = self
stocksTableView.rowHeight = 50.0
addSubview(stocksTableView)

searchBarView.snp_makeConstraints { (make) in
make.top.equalTo(self.snp_top)
make.left.equalTo(self.snp_left)
make.right.equalTo(self.snp_right)
searchBarView.snp.makeConstraints { (make) in
make.top.equalTo(self.snp.top)
make.left.equalTo(self.snp.left)
make.right.equalTo(self.snp.right)
make.height.equalTo(50)
}

searchTextField.snp_makeConstraints { (make) in
searchTextField.snp.makeConstraints { (make) in
make.top.equalTo(searchBarView).offset(10)
make.left.equalTo(searchBarView).offset(10)
make.right.equalTo(searchBarView).offset(-10)
make.bottom.equalTo(searchBarView).offset(-10)
}

stocksTableView.snp_makeConstraints { (make) in
make.top.equalTo(searchBarView.snp_bottom)
stocksTableView.snp.makeConstraints { (make) in
make.top.equalTo(searchBarView.snp.bottom)
make.left.equalTo(self)
make.right.equalTo(self)
make.bottom.equalTo(self)
Expand All @@ -77,41 +77,41 @@ class ExampleAddStockView: UIView, UITableViewDataSource, UITableViewDelegate {

// MARK: UITableViewDataSource and UITableViewDataSource Implementation

func numberOfSectionsInTableView(tableView: UITableView) -> Int {
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return delegate!.numberOfSearchResultStocks()
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

let reuseIdentifier = "ExampleCell"

var cell = tableView.dequeueReusableCellWithIdentifier(reuseIdentifier) as UITableViewCell?
var cell = tableView.dequeueReusableCell(withIdentifier: reuseIdentifier) as UITableViewCell?

if cell == nil {
cell = UITableViewCell(style: .Subtitle, reuseIdentifier: reuseIdentifier)
let exchangeLabel = UILabel(frame: CGRectMake(0, 0, 150, 25))
exchangeLabel.textAlignment = .Right
cell = UITableViewCell(style: .subtitle, reuseIdentifier: reuseIdentifier)
let exchangeLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 150, height: 25))
exchangeLabel.textAlignment = .right
cell?.accessoryView = exchangeLabel
}

return cell!
}

func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
let stock = delegate!.searchResultStockAtIndex(indexPath.row)
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
let stock = delegate!.searchResultStockAtIndex((indexPath as NSIndexPath).row)
cell.textLabel?.text = stock.name!
cell.detailTextLabel?.text = stock.symbol!
let exchangeLabel = cell.accessoryView as! UILabel!
exchangeLabel.text = stock.exch!
exchangeLabel?.text = stock.exch!
}

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: false)
delegate!.stockResultSelectedAtIndex(indexPath.row)
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: false)
delegate!.stockResultSelectedAtIndex((indexPath as NSIndexPath).row)
}

}
12 changes: 6 additions & 6 deletions Example/BigBoard/ExampleAddStockViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class ExampleAddStockViewController: UIViewController, ExampleAddStockViewDelega
var exampleView:ExampleAddStockView!
var selectionCallback:((BigBoardSearchResultStock) -> Void)!

init(selectionCallback:((BigBoardSearchResultStock) -> Void)){
init(selectionCallback:@escaping ((BigBoardSearchResultStock) -> Void)){
super.init(nibName: nil, bundle: nil)
edgesForExtendedLayout = .None
edgesForExtendedLayout = UIRectEdge()
self.selectionCallback = selectionCallback
model = ExampleAddStockModel()
exampleView = ExampleAddStockView(delegate: self)
Expand All @@ -34,20 +34,20 @@ class ExampleAddStockViewController: UIViewController, ExampleAddStockViewDelega
return model.numberOfSearchResultStocks()
}

func searchResultStockAtIndex(index:Int) -> BigBoardSearchResultStock {
func searchResultStockAtIndex(_ index:Int) -> BigBoardSearchResultStock {
return model.searchResultStockAtIndex(index)
}

func searchTermChanged(searchTerm searchTerm:String) {
func searchTermChanged(searchTerm:String) {
model.fetchStocksForSearchTerm(searchTerm, success: {
self.exampleView.stocksTableView.reloadData()
}) { (error) in
print(error)
}
}

func stockResultSelectedAtIndex(index: Int) {
func stockResultSelectedAtIndex(_ index: Int) {
selectionCallback(searchResultStockAtIndex(index))
navigationController!.popViewControllerAnimated(true)
navigationController!.popViewController(animated: true)
}
}
14 changes: 7 additions & 7 deletions Example/BigBoard/ExampleModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,33 @@ class ExampleModel: NSObject {
return stocks.count
}

func stockAtIndex(index:Int) -> BigBoardStock {
func stockAtIndex(_ index:Int) -> BigBoardStock {
return stocks[index]
}

func refreshStocks(success success:(() -> Void), failure:(BigBoardError) -> Void) {
func refreshStocks(success:@escaping (() -> Void), failure:@escaping (BigBoardError) -> Void) {

var stockSymbols:[String] = []

for stock in stocks {
stockSymbols.append(stock.symbol!)
}

BigBoard.stocksWithSymbols(symbols: stockSymbols, success: { (stocks) in
_ = BigBoard.stocksWithSymbols(symbols: stockSymbols, success: { (stocks) in
self.stocks = stocks
success()
}, failure: failure)
}

func mapSampleStocks(success success:(() -> Void), failure:((BigBoardError) -> Void)) {
BigBoard.stocksWithSymbols(symbols: ["GOOG", "AAPL", "TSLA"], success: { (stocks) in
func mapSampleStocks(success:@escaping (() -> Void), failure:@escaping ((BigBoardError) -> Void)) {
_ = BigBoard.stocksWithSymbols(symbols: ["GOOG", "AAPL", "TSLA"], success: { (stocks) in
self.stocks = stocks
success()
}, failure: failure)
}

func mapStockWithSymbol(symbol symbol:String, success:(() -> Void), failure:((BigBoardError) -> Void)) {
BigBoard.stockWithSymbol(symbol: symbol, success: { (stock) in
func mapStockWithSymbol(symbol:String, success:@escaping (() -> Void), failure:@escaping ((BigBoardError) -> Void)) {
_ = BigBoard.stockWithSymbol(symbol: symbol, success: { (stock) in
self.stocks.append(stock)
success()
}, failure: failure)
Expand Down
6 changes: 3 additions & 3 deletions Example/BigBoard/ExampleStockDetailsModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ class ExampleStockDetailsModel: NSObject {
}
}

func rssFeedItemAtIndex(index:Int) -> BigBoardRSSFeedItem {
func rssFeedItemAtIndex(_ index:Int) -> BigBoardRSSFeedItem {
return rssFeed.items![index]
}

func loadRSSFeed(success success:(() -> Void), failure:((BigBoardError) -> Void)) {
BigBoard.rssFeedForStockWithSymbol(symbol: stock.symbol!, success: { (feed) in
func loadRSSFeed(success:@escaping (() -> Void), failure:@escaping ((BigBoardError) -> Void)) {
_ = BigBoard.rssFeedForStockWithSymbol(symbol: stock.symbol!, success: { (feed) in
self.rssFeed = feed
success()
}) { (error) in
Expand Down
Loading

0 comments on commit 26568d9

Please sign in to comment.