Skip to content

Instantly share code, notes, and snippets.

@fedejordan
Created February 19, 2018 05:10
Show Gist options
  • Save fedejordan/9834e4c93d44671ec757eeef29ec2127 to your computer and use it in GitHub Desktop.
Save fedejordan/9834e4c93d44671ec757eeef29ec2127 to your computer and use it in GitHub Desktop.
Blog02 - ItemsInteractor
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