Created
February 19, 2018 05:10
-
-
Save fedejordan/9834e4c93d44671ec757eeef29ec2127 to your computer and use it in GitHub Desktop.
Blog02 - ItemsInteractor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ItemsInteractor { | |
private var items = [Item]() | |
func loadData() { | |
items.append(Item(name: "Apple", image: UIImage(named: "apple")!)) | |
items.append(Item(name: "Banana", image: UIImage(named: "banana")!)) | |
items.append(Item(name: "Potato", image: UIImage(named: "potato")!)) | |
} | |
func itemsCount() -> Int { | |
return items.count | |
} | |
func itemImage(atIndex index: Int) -> UIImage { | |
return items[index].image | |
} | |
func itemName(atIndex index: Int) -> String { | |
return items[index].name | |
} | |
func didSelectItem(atIndex index: Int) { | |
let item = items[index] | |
print("Selected " + item.name + " at index: \(index)") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment