From a8c3db459cc1be105dd910efb8bbc08bc163fb91 Mon Sep 17 00:00:00 2001 From: Nicholas Tay Date: Mon, 14 Mar 2022 15:47:36 +1100 Subject: Learning UITableViewController: array data + custom cells Forgot to commit after finishing just the using array data bit. So committing with the custom cells done. https://www.ralfebert.com/ios-examples/uikit/uitableviewcontroller/ --- foray.xcodeproj/project.pbxproj | 10 +-- .../AppIcon.appiconset/Contents.json | 18 +++++ .../AppIcon.appiconset/rbt-1024.png | Bin 0 -> 160368 bytes .../Assets.xcassets/AppIcon.appiconset/rbt-20.png | Bin 0 -> 1790 bytes .../AppIcon.appiconset/rbt-20@2x.png | Bin 0 -> 2890 bytes .../AppIcon.appiconset/rbt-20@3x.png | Bin 0 -> 4190 bytes .../Assets.xcassets/AppIcon.appiconset/rbt-29.png | Bin 0 -> 2244 bytes .../AppIcon.appiconset/rbt-29@2x.png | Bin 0 -> 4064 bytes .../AppIcon.appiconset/rbt-29@3x.png | Bin 0 -> 6185 bytes .../Assets.xcassets/AppIcon.appiconset/rbt-40.png | Bin 0 -> 2890 bytes .../AppIcon.appiconset/rbt-40@2x.png | Bin 0 -> 5655 bytes .../AppIcon.appiconset/rbt-40@3x.png | Bin 0 -> 8954 bytes .../AppIcon.appiconset/rbt-60@2x.png | Bin 0 -> 8954 bytes .../AppIcon.appiconset/rbt-60@3x.png | Bin 0 -> 14639 bytes .../Assets.xcassets/AppIcon.appiconset/rbt-76.png | Bin 0 -> 5302 bytes .../AppIcon.appiconset/rbt-76@2x.png | Bin 0 -> 11968 bytes .../AppIcon.appiconset/rbt-83.5@2x.png | Bin 0 -> 13377 bytes foray/Assets.xcassets/bnb.imageset/Contents.json | 21 ++++++ foray/Assets.xcassets/bnb.imageset/bnb.png | Bin 0 -> 16325 bytes foray/Assets.xcassets/it.imageset/Contents.json | 21 ++++++ foray/Assets.xcassets/it.imageset/it.png | Bin 0 -> 287329 bytes foray/Assets.xcassets/mh.imageset/Contents.json | 21 ++++++ foray/Assets.xcassets/mh.imageset/mh.png | Bin 0 -> 174713 bytes foray/Assets.xcassets/spy.imageset/Contents.json | 21 ++++++ foray/Assets.xcassets/spy.imageset/spy.png | Bin 0 -> 135988 bytes foray/Assets.xcassets/tbg.imageset/Contents.json | 21 ++++++ foray/Assets.xcassets/tbg.imageset/tbg.png | Bin 0 -> 30866 bytes foray/Base.lproj/Main.storyboard | 75 +++++++++++++++++---- foray/ForayTableViewController.swift | 59 ++++++++++++++++ foray/ViewController.swift | 19 ------ 30 files changed, 250 insertions(+), 36 deletions(-) create mode 100644 foray/Assets.xcassets/AppIcon.appiconset/rbt-1024.png create mode 100644 foray/Assets.xcassets/AppIcon.appiconset/rbt-20.png create mode 100644 foray/Assets.xcassets/AppIcon.appiconset/rbt-20@2x.png create mode 100644 foray/Assets.xcassets/AppIcon.appiconset/rbt-20@3x.png create mode 100644 foray/Assets.xcassets/AppIcon.appiconset/rbt-29.png create mode 100644 foray/Assets.xcassets/AppIcon.appiconset/rbt-29@2x.png create mode 100644 foray/Assets.xcassets/AppIcon.appiconset/rbt-29@3x.png create mode 100644 foray/Assets.xcassets/AppIcon.appiconset/rbt-40.png create mode 100644 foray/Assets.xcassets/AppIcon.appiconset/rbt-40@2x.png create mode 100644 foray/Assets.xcassets/AppIcon.appiconset/rbt-40@3x.png create mode 100644 foray/Assets.xcassets/AppIcon.appiconset/rbt-60@2x.png create mode 100644 foray/Assets.xcassets/AppIcon.appiconset/rbt-60@3x.png create mode 100644 foray/Assets.xcassets/AppIcon.appiconset/rbt-76.png create mode 100644 foray/Assets.xcassets/AppIcon.appiconset/rbt-76@2x.png create mode 100644 foray/Assets.xcassets/AppIcon.appiconset/rbt-83.5@2x.png create mode 100644 foray/Assets.xcassets/bnb.imageset/Contents.json create mode 100644 foray/Assets.xcassets/bnb.imageset/bnb.png create mode 100644 foray/Assets.xcassets/it.imageset/Contents.json create mode 100644 foray/Assets.xcassets/it.imageset/it.png create mode 100644 foray/Assets.xcassets/mh.imageset/Contents.json create mode 100644 foray/Assets.xcassets/mh.imageset/mh.png create mode 100644 foray/Assets.xcassets/spy.imageset/Contents.json create mode 100644 foray/Assets.xcassets/spy.imageset/spy.png create mode 100644 foray/Assets.xcassets/tbg.imageset/Contents.json create mode 100644 foray/Assets.xcassets/tbg.imageset/tbg.png create mode 100644 foray/ForayTableViewController.swift delete mode 100644 foray/ViewController.swift diff --git a/foray.xcodeproj/project.pbxproj b/foray.xcodeproj/project.pbxproj index 52d5a18..6df1a30 100644 --- a/foray.xcodeproj/project.pbxproj +++ b/foray.xcodeproj/project.pbxproj @@ -9,21 +9,21 @@ /* Begin PBXBuildFile section */ C04B45A427DEF117001451A3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04B45A327DEF117001451A3 /* AppDelegate.swift */; }; C04B45A627DEF117001451A3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04B45A527DEF117001451A3 /* SceneDelegate.swift */; }; - C04B45A827DEF117001451A3 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04B45A727DEF117001451A3 /* ViewController.swift */; }; C04B45AB27DEF117001451A3 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C04B45A927DEF117001451A3 /* Main.storyboard */; }; C04B45AD27DEF118001451A3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C04B45AC27DEF118001451A3 /* Assets.xcassets */; }; C04B45B027DEF118001451A3 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C04B45AE27DEF118001451A3 /* LaunchScreen.storyboard */; }; + C04B45B827DEF2ED001451A3 /* ForayTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04B45B727DEF2ED001451A3 /* ForayTableViewController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ C04B45A027DEF117001451A3 /* foray.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = foray.app; sourceTree = BUILT_PRODUCTS_DIR; }; C04B45A327DEF117001451A3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; C04B45A527DEF117001451A3 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; - C04B45A727DEF117001451A3 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; C04B45AA27DEF117001451A3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; C04B45AC27DEF118001451A3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; C04B45AF27DEF118001451A3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; C04B45B127DEF118001451A3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C04B45B727DEF2ED001451A3 /* ForayTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForayTableViewController.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -58,8 +58,8 @@ children = ( C04B45A327DEF117001451A3 /* AppDelegate.swift */, C04B45A527DEF117001451A3 /* SceneDelegate.swift */, - C04B45A727DEF117001451A3 /* ViewController.swift */, C04B45A927DEF117001451A3 /* Main.storyboard */, + C04B45B727DEF2ED001451A3 /* ForayTableViewController.swift */, C04B45AC27DEF118001451A3 /* Assets.xcassets */, C04B45AE27DEF118001451A3 /* LaunchScreen.storyboard */, C04B45B127DEF118001451A3 /* Info.plist */, @@ -138,7 +138,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - C04B45A827DEF117001451A3 /* ViewController.swift in Sources */, + C04B45B827DEF2ED001451A3 /* ForayTableViewController.swift in Sources */, C04B45A427DEF117001451A3 /* AppDelegate.swift in Sources */, C04B45A627DEF117001451A3 /* SceneDelegate.swift in Sources */, ); @@ -292,6 +292,7 @@ DEVELOPMENT_TEAM = 6DXVFJU35J; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = foray/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = Foray; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UIMainStoryboardFile = Main; @@ -320,6 +321,7 @@ DEVELOPMENT_TEAM = 6DXVFJU35J; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = foray/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = Foray; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UIMainStoryboardFile = Main; diff --git a/foray/Assets.xcassets/AppIcon.appiconset/Contents.json b/foray/Assets.xcassets/AppIcon.appiconset/Contents.json index 9221b9b..995ee2f 100644 --- a/foray/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/foray/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,91 +1,109 @@ { "images" : [ { + "filename" : "rbt-20@2x.png", "idiom" : "iphone", "scale" : "2x", "size" : "20x20" }, { + "filename" : "rbt-20@3x.png", "idiom" : "iphone", "scale" : "3x", "size" : "20x20" }, { + "filename" : "rbt-29@2x.png", "idiom" : "iphone", "scale" : "2x", "size" : "29x29" }, { + "filename" : "rbt-29@3x.png", "idiom" : "iphone", "scale" : "3x", "size" : "29x29" }, { + "filename" : "rbt-40@2x.png", "idiom" : "iphone", "scale" : "2x", "size" : "40x40" }, { + "filename" : "rbt-40@3x.png", "idiom" : "iphone", "scale" : "3x", "size" : "40x40" }, { + "filename" : "rbt-60@2x.png", "idiom" : "iphone", "scale" : "2x", "size" : "60x60" }, { + "filename" : "rbt-60@3x.png", "idiom" : "iphone", "scale" : "3x", "size" : "60x60" }, { + "filename" : "rbt-20.png", "idiom" : "ipad", "scale" : "1x", "size" : "20x20" }, { + "filename" : "rbt-20@2x.png", "idiom" : "ipad", "scale" : "2x", "size" : "20x20" }, { + "filename" : "rbt-29.png", "idiom" : "ipad", "scale" : "1x", "size" : "29x29" }, { + "filename" : "rbt-29@2x.png", "idiom" : "ipad", "scale" : "2x", "size" : "29x29" }, { + "filename" : "rbt-40.png", "idiom" : "ipad", "scale" : "1x", "size" : "40x40" }, { + "filename" : "rbt-40@2x.png", "idiom" : "ipad", "scale" : "2x", "size" : "40x40" }, { + "filename" : "rbt-76.png", "idiom" : "ipad", "scale" : "1x", "size" : "76x76" }, { + "filename" : "rbt-76@2x.png", "idiom" : "ipad", "scale" : "2x", "size" : "76x76" }, { + "filename" : "rbt-83.5@2x.png", "idiom" : "ipad", "scale" : "2x", "size" : "83.5x83.5" }, { + "filename" : "rbt-1024.png", "idiom" : "ios-marketing", "scale" : "1x", "size" : "1024x1024" diff --git a/foray/Assets.xcassets/AppIcon.appiconset/rbt-1024.png b/foray/Assets.xcassets/AppIcon.appiconset/rbt-1024.png new file mode 100644 index 0000000..0497ff3 Binary files /dev/null and b/foray/Assets.xcassets/AppIcon.appiconset/rbt-1024.png differ diff --git a/foray/Assets.xcassets/AppIcon.appiconset/rbt-20.png b/foray/Assets.xcassets/AppIcon.appiconset/rbt-20.png new file mode 100644 index 0000000..7227ece Binary files /dev/null and b/foray/Assets.xcassets/AppIcon.appiconset/rbt-20.png differ diff --git a/foray/Assets.xcassets/AppIcon.appiconset/rbt-20@2x.png b/foray/Assets.xcassets/AppIcon.appiconset/rbt-20@2x.png new file mode 100644 index 0000000..a8e97e9 Binary files /dev/null and b/foray/Assets.xcassets/AppIcon.appiconset/rbt-20@2x.png differ diff --git a/foray/Assets.xcassets/AppIcon.appiconset/rbt-20@3x.png b/foray/Assets.xcassets/AppIcon.appiconset/rbt-20@3x.png new file mode 100644 index 0000000..e4738a9 Binary files /dev/null and b/foray/Assets.xcassets/AppIcon.appiconset/rbt-20@3x.png differ diff --git a/foray/Assets.xcassets/AppIcon.appiconset/rbt-29.png b/foray/Assets.xcassets/AppIcon.appiconset/rbt-29.png new file mode 100644 index 0000000..bb7c736 Binary files /dev/null and b/foray/Assets.xcassets/AppIcon.appiconset/rbt-29.png differ diff --git a/foray/Assets.xcassets/AppIcon.appiconset/rbt-29@2x.png b/foray/Assets.xcassets/AppIcon.appiconset/rbt-29@2x.png new file mode 100644 index 0000000..5415390 Binary files /dev/null and b/foray/Assets.xcassets/AppIcon.appiconset/rbt-29@2x.png differ diff --git a/foray/Assets.xcassets/AppIcon.appiconset/rbt-29@3x.png b/foray/Assets.xcassets/AppIcon.appiconset/rbt-29@3x.png new file mode 100644 index 0000000..d884864 Binary files /dev/null and b/foray/Assets.xcassets/AppIcon.appiconset/rbt-29@3x.png differ diff --git a/foray/Assets.xcassets/AppIcon.appiconset/rbt-40.png b/foray/Assets.xcassets/AppIcon.appiconset/rbt-40.png new file mode 100644 index 0000000..a8e97e9 Binary files /dev/null and b/foray/Assets.xcassets/AppIcon.appiconset/rbt-40.png differ diff --git a/foray/Assets.xcassets/AppIcon.appiconset/rbt-40@2x.png b/foray/Assets.xcassets/AppIcon.appiconset/rbt-40@2x.png new file mode 100644 index 0000000..e4f5b5e Binary files /dev/null and b/foray/Assets.xcassets/AppIcon.appiconset/rbt-40@2x.png differ diff --git a/foray/Assets.xcassets/AppIcon.appiconset/rbt-40@3x.png b/foray/Assets.xcassets/AppIcon.appiconset/rbt-40@3x.png new file mode 100644 index 0000000..3f6ad84 Binary files /dev/null and b/foray/Assets.xcassets/AppIcon.appiconset/rbt-40@3x.png differ diff --git a/foray/Assets.xcassets/AppIcon.appiconset/rbt-60@2x.png b/foray/Assets.xcassets/AppIcon.appiconset/rbt-60@2x.png new file mode 100644 index 0000000..3f6ad84 Binary files /dev/null and b/foray/Assets.xcassets/AppIcon.appiconset/rbt-60@2x.png differ diff --git a/foray/Assets.xcassets/AppIcon.appiconset/rbt-60@3x.png b/foray/Assets.xcassets/AppIcon.appiconset/rbt-60@3x.png new file mode 100644 index 0000000..387990b Binary files /dev/null and b/foray/Assets.xcassets/AppIcon.appiconset/rbt-60@3x.png differ diff --git a/foray/Assets.xcassets/AppIcon.appiconset/rbt-76.png b/foray/Assets.xcassets/AppIcon.appiconset/rbt-76.png new file mode 100644 index 0000000..a099901 Binary files /dev/null and b/foray/Assets.xcassets/AppIcon.appiconset/rbt-76.png differ diff --git a/foray/Assets.xcassets/AppIcon.appiconset/rbt-76@2x.png b/foray/Assets.xcassets/AppIcon.appiconset/rbt-76@2x.png new file mode 100644 index 0000000..c3087cb Binary files /dev/null and b/foray/Assets.xcassets/AppIcon.appiconset/rbt-76@2x.png differ diff --git a/foray/Assets.xcassets/AppIcon.appiconset/rbt-83.5@2x.png b/foray/Assets.xcassets/AppIcon.appiconset/rbt-83.5@2x.png new file mode 100644 index 0000000..7f60014 Binary files /dev/null and b/foray/Assets.xcassets/AppIcon.appiconset/rbt-83.5@2x.png differ diff --git a/foray/Assets.xcassets/bnb.imageset/Contents.json b/foray/Assets.xcassets/bnb.imageset/Contents.json new file mode 100644 index 0000000..754ecd5 --- /dev/null +++ b/foray/Assets.xcassets/bnb.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "bnb.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/foray/Assets.xcassets/bnb.imageset/bnb.png b/foray/Assets.xcassets/bnb.imageset/bnb.png new file mode 100644 index 0000000..d7fed27 Binary files /dev/null and b/foray/Assets.xcassets/bnb.imageset/bnb.png differ diff --git a/foray/Assets.xcassets/it.imageset/Contents.json b/foray/Assets.xcassets/it.imageset/Contents.json new file mode 100644 index 0000000..505c0ec --- /dev/null +++ b/foray/Assets.xcassets/it.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "it.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/foray/Assets.xcassets/it.imageset/it.png b/foray/Assets.xcassets/it.imageset/it.png new file mode 100644 index 0000000..da65be4 Binary files /dev/null and b/foray/Assets.xcassets/it.imageset/it.png differ diff --git a/foray/Assets.xcassets/mh.imageset/Contents.json b/foray/Assets.xcassets/mh.imageset/Contents.json new file mode 100644 index 0000000..b2edaaa --- /dev/null +++ b/foray/Assets.xcassets/mh.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "mh.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/foray/Assets.xcassets/mh.imageset/mh.png b/foray/Assets.xcassets/mh.imageset/mh.png new file mode 100644 index 0000000..22f9125 Binary files /dev/null and b/foray/Assets.xcassets/mh.imageset/mh.png differ diff --git a/foray/Assets.xcassets/spy.imageset/Contents.json b/foray/Assets.xcassets/spy.imageset/Contents.json new file mode 100644 index 0000000..feac6bb --- /dev/null +++ b/foray/Assets.xcassets/spy.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "spy.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/foray/Assets.xcassets/spy.imageset/spy.png b/foray/Assets.xcassets/spy.imageset/spy.png new file mode 100644 index 0000000..c8d88df Binary files /dev/null and b/foray/Assets.xcassets/spy.imageset/spy.png differ diff --git a/foray/Assets.xcassets/tbg.imageset/Contents.json b/foray/Assets.xcassets/tbg.imageset/Contents.json new file mode 100644 index 0000000..eca59d1 --- /dev/null +++ b/foray/Assets.xcassets/tbg.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "tbg.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/foray/Assets.xcassets/tbg.imageset/tbg.png b/foray/Assets.xcassets/tbg.imageset/tbg.png new file mode 100644 index 0000000..83018da Binary files /dev/null and b/foray/Assets.xcassets/tbg.imageset/tbg.png differ diff --git a/foray/Base.lproj/Main.storyboard b/foray/Base.lproj/Main.storyboard index 25a7638..7af2493 100644 --- a/foray/Base.lproj/Main.storyboard +++ b/foray/Base.lproj/Main.storyboard @@ -1,24 +1,73 @@ - + + - - + - - + + - - - + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/foray/ForayTableViewController.swift b/foray/ForayTableViewController.swift new file mode 100644 index 0000000..66e9274 --- /dev/null +++ b/foray/ForayTableViewController.swift @@ -0,0 +1,59 @@ +// +// ForayTableViewController.swift +// foray +// +// Created by Nicholas Tay on 14/3/2022. +// + +import UIKit + +struct MyItem { + var id: String + var name: String +} + +class ForayTableViewCell: UITableViewCell { + @IBOutlet weak var cellItemName: UILabel! + @IBOutlet weak var cellItemSubtitle: UILabel! + @IBOutlet weak var cellItemImage: UIImageView! +} + +class ForayTableViewController: UITableViewController { + + // MARK: - Static data TEMP + + let items = [ + MyItem(id: "mh", name: "Miners Helmet"), + MyItem(id: "it", name: "Inner Tube"), + MyItem(id: "tbg", name: "Toboggan"), + MyItem(id: "spy", name: "Spy Phone"), + MyItem(id: "bnb", name: "Black Ninja Belt"), + ] + + // MARK: - Table view data source + + override func numberOfSections(in tableView: UITableView) -> Int { + // Returns number of sections for table + return 1 + } + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + // Returns number of rows for table + return items.count + } + + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: "ForayCell", for: indexPath) as! ForayTableViewCell + + let item = items[indexPath.row] + cell.cellItemName?.text = item.name + cell.cellItemSubtitle?.text = "Item ID: \(item.id)" + cell.cellItemImage?.image = UIImage(named: item.id) + + return cell + } + + override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + return "Section \(section)" + } +} diff --git a/foray/ViewController.swift b/foray/ViewController.swift deleted file mode 100644 index 7b442c4..0000000 --- a/foray/ViewController.swift +++ /dev/null @@ -1,19 +0,0 @@ -// -// ViewController.swift -// foray -// -// Created by Nicholas Tay on 14/3/2022. -// - -import UIKit - -class ViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - // Do any additional setup after loading the view. - } - - -} - -- cgit