├── GenericTableView.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcuserdata │ └── alfianlosari.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── GenericTableView ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Cell.swift ├── GenericTableViewController.swift ├── Info.plist ├── LauncScreen.storyboard └── Model.swift └── README.md /GenericTableView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 8B5D49902189CBFA008E458C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B5D498F2189CBFA008E458C /* AppDelegate.swift */; }; 11 | 8B5D49922189CBFA008E458C /* GenericTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B5D49912189CBFA008E458C /* GenericTableViewController.swift */; }; 12 | 8B5D49972189CBFC008E458C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8B5D49962189CBFC008E458C /* Assets.xcassets */; }; 13 | 8B5D49A2218A9B5D008E458C /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B5D49A1218A9B5D008E458C /* Model.swift */; }; 14 | 8B5D49A4218A9B7B008E458C /* Cell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B5D49A3218A9B7B008E458C /* Cell.swift */; }; 15 | 8B5D49A6218A9D57008E458C /* LauncScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8B5D49A5218A9D57008E458C /* LauncScreen.storyboard */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | 8B5D498C2189CBFA008E458C /* GenericTableView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GenericTableView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | 8B5D498F2189CBFA008E458C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 21 | 8B5D49912189CBFA008E458C /* GenericTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenericTableViewController.swift; sourceTree = ""; }; 22 | 8B5D49962189CBFC008E458C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 23 | 8B5D499B2189CBFC008E458C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 24 | 8B5D49A1218A9B5D008E458C /* Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Model.swift; sourceTree = ""; }; 25 | 8B5D49A3218A9B7B008E458C /* Cell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Cell.swift; sourceTree = ""; }; 26 | 8B5D49A5218A9D57008E458C /* LauncScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LauncScreen.storyboard; sourceTree = ""; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | 8B5D49892189CBFA008E458C /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | ); 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXFrameworksBuildPhase section */ 38 | 39 | /* Begin PBXGroup section */ 40 | 8B5D49832189CBFA008E458C = { 41 | isa = PBXGroup; 42 | children = ( 43 | 8B5D498E2189CBFA008E458C /* GenericTableView */, 44 | 8B5D498D2189CBFA008E458C /* Products */, 45 | ); 46 | sourceTree = ""; 47 | }; 48 | 8B5D498D2189CBFA008E458C /* Products */ = { 49 | isa = PBXGroup; 50 | children = ( 51 | 8B5D498C2189CBFA008E458C /* GenericTableView.app */, 52 | ); 53 | name = Products; 54 | sourceTree = ""; 55 | }; 56 | 8B5D498E2189CBFA008E458C /* GenericTableView */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | 8B5D498F2189CBFA008E458C /* AppDelegate.swift */, 60 | 8B5D49912189CBFA008E458C /* GenericTableViewController.swift */, 61 | 8B5D49A1218A9B5D008E458C /* Model.swift */, 62 | 8B5D49A3218A9B7B008E458C /* Cell.swift */, 63 | 8B5D49962189CBFC008E458C /* Assets.xcassets */, 64 | 8B5D499B2189CBFC008E458C /* Info.plist */, 65 | 8B5D49A5218A9D57008E458C /* LauncScreen.storyboard */, 66 | ); 67 | path = GenericTableView; 68 | sourceTree = ""; 69 | }; 70 | /* End PBXGroup section */ 71 | 72 | /* Begin PBXNativeTarget section */ 73 | 8B5D498B2189CBFA008E458C /* GenericTableView */ = { 74 | isa = PBXNativeTarget; 75 | buildConfigurationList = 8B5D499E2189CBFC008E458C /* Build configuration list for PBXNativeTarget "GenericTableView" */; 76 | buildPhases = ( 77 | 8B5D49882189CBFA008E458C /* Sources */, 78 | 8B5D49892189CBFA008E458C /* Frameworks */, 79 | 8B5D498A2189CBFA008E458C /* Resources */, 80 | ); 81 | buildRules = ( 82 | ); 83 | dependencies = ( 84 | ); 85 | name = GenericTableView; 86 | productName = GenericTableView; 87 | productReference = 8B5D498C2189CBFA008E458C /* GenericTableView.app */; 88 | productType = "com.apple.product-type.application"; 89 | }; 90 | /* End PBXNativeTarget section */ 91 | 92 | /* Begin PBXProject section */ 93 | 8B5D49842189CBFA008E458C /* Project object */ = { 94 | isa = PBXProject; 95 | attributes = { 96 | LastSwiftUpdateCheck = 1000; 97 | LastUpgradeCheck = 1000; 98 | ORGANIZATIONNAME = alfianlosari; 99 | TargetAttributes = { 100 | 8B5D498B2189CBFA008E458C = { 101 | CreatedOnToolsVersion = 10.0; 102 | }; 103 | }; 104 | }; 105 | buildConfigurationList = 8B5D49872189CBFA008E458C /* Build configuration list for PBXProject "GenericTableView" */; 106 | compatibilityVersion = "Xcode 9.3"; 107 | developmentRegion = en; 108 | hasScannedForEncodings = 0; 109 | knownRegions = ( 110 | en, 111 | Base, 112 | ); 113 | mainGroup = 8B5D49832189CBFA008E458C; 114 | productRefGroup = 8B5D498D2189CBFA008E458C /* Products */; 115 | projectDirPath = ""; 116 | projectRoot = ""; 117 | targets = ( 118 | 8B5D498B2189CBFA008E458C /* GenericTableView */, 119 | ); 120 | }; 121 | /* End PBXProject section */ 122 | 123 | /* Begin PBXResourcesBuildPhase section */ 124 | 8B5D498A2189CBFA008E458C /* Resources */ = { 125 | isa = PBXResourcesBuildPhase; 126 | buildActionMask = 2147483647; 127 | files = ( 128 | 8B5D49A6218A9D57008E458C /* LauncScreen.storyboard in Resources */, 129 | 8B5D49972189CBFC008E458C /* Assets.xcassets in Resources */, 130 | ); 131 | runOnlyForDeploymentPostprocessing = 0; 132 | }; 133 | /* End PBXResourcesBuildPhase section */ 134 | 135 | /* Begin PBXSourcesBuildPhase section */ 136 | 8B5D49882189CBFA008E458C /* Sources */ = { 137 | isa = PBXSourcesBuildPhase; 138 | buildActionMask = 2147483647; 139 | files = ( 140 | 8B5D49A2218A9B5D008E458C /* Model.swift in Sources */, 141 | 8B5D49A4218A9B7B008E458C /* Cell.swift in Sources */, 142 | 8B5D49922189CBFA008E458C /* GenericTableViewController.swift in Sources */, 143 | 8B5D49902189CBFA008E458C /* AppDelegate.swift in Sources */, 144 | ); 145 | runOnlyForDeploymentPostprocessing = 0; 146 | }; 147 | /* End PBXSourcesBuildPhase section */ 148 | 149 | /* Begin XCBuildConfiguration section */ 150 | 8B5D499C2189CBFC008E458C /* Debug */ = { 151 | isa = XCBuildConfiguration; 152 | buildSettings = { 153 | ALWAYS_SEARCH_USER_PATHS = NO; 154 | CLANG_ANALYZER_NONNULL = YES; 155 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 156 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 157 | CLANG_CXX_LIBRARY = "libc++"; 158 | CLANG_ENABLE_MODULES = YES; 159 | CLANG_ENABLE_OBJC_ARC = YES; 160 | CLANG_ENABLE_OBJC_WEAK = YES; 161 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 162 | CLANG_WARN_BOOL_CONVERSION = YES; 163 | CLANG_WARN_COMMA = YES; 164 | CLANG_WARN_CONSTANT_CONVERSION = YES; 165 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 166 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 167 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 168 | CLANG_WARN_EMPTY_BODY = YES; 169 | CLANG_WARN_ENUM_CONVERSION = YES; 170 | CLANG_WARN_INFINITE_RECURSION = YES; 171 | CLANG_WARN_INT_CONVERSION = YES; 172 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 173 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 174 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 175 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 176 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 177 | CLANG_WARN_STRICT_PROTOTYPES = YES; 178 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 179 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 180 | CLANG_WARN_UNREACHABLE_CODE = YES; 181 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 182 | CODE_SIGN_IDENTITY = "iPhone Developer"; 183 | COPY_PHASE_STRIP = NO; 184 | DEBUG_INFORMATION_FORMAT = dwarf; 185 | ENABLE_STRICT_OBJC_MSGSEND = YES; 186 | ENABLE_TESTABILITY = YES; 187 | GCC_C_LANGUAGE_STANDARD = gnu11; 188 | GCC_DYNAMIC_NO_PIC = NO; 189 | GCC_NO_COMMON_BLOCKS = YES; 190 | GCC_OPTIMIZATION_LEVEL = 0; 191 | GCC_PREPROCESSOR_DEFINITIONS = ( 192 | "DEBUG=1", 193 | "$(inherited)", 194 | ); 195 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 196 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 197 | GCC_WARN_UNDECLARED_SELECTOR = YES; 198 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 199 | GCC_WARN_UNUSED_FUNCTION = YES; 200 | GCC_WARN_UNUSED_VARIABLE = YES; 201 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 202 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 203 | MTL_FAST_MATH = YES; 204 | ONLY_ACTIVE_ARCH = YES; 205 | SDKROOT = iphoneos; 206 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 207 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 208 | }; 209 | name = Debug; 210 | }; 211 | 8B5D499D2189CBFC008E458C /* Release */ = { 212 | isa = XCBuildConfiguration; 213 | buildSettings = { 214 | ALWAYS_SEARCH_USER_PATHS = NO; 215 | CLANG_ANALYZER_NONNULL = YES; 216 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 217 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 218 | CLANG_CXX_LIBRARY = "libc++"; 219 | CLANG_ENABLE_MODULES = YES; 220 | CLANG_ENABLE_OBJC_ARC = YES; 221 | CLANG_ENABLE_OBJC_WEAK = YES; 222 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 223 | CLANG_WARN_BOOL_CONVERSION = YES; 224 | CLANG_WARN_COMMA = YES; 225 | CLANG_WARN_CONSTANT_CONVERSION = YES; 226 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 227 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 228 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 229 | CLANG_WARN_EMPTY_BODY = YES; 230 | CLANG_WARN_ENUM_CONVERSION = YES; 231 | CLANG_WARN_INFINITE_RECURSION = YES; 232 | CLANG_WARN_INT_CONVERSION = YES; 233 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 234 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 235 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 236 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 237 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 238 | CLANG_WARN_STRICT_PROTOTYPES = YES; 239 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 240 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 241 | CLANG_WARN_UNREACHABLE_CODE = YES; 242 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 243 | CODE_SIGN_IDENTITY = "iPhone Developer"; 244 | COPY_PHASE_STRIP = NO; 245 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 246 | ENABLE_NS_ASSERTIONS = NO; 247 | ENABLE_STRICT_OBJC_MSGSEND = YES; 248 | GCC_C_LANGUAGE_STANDARD = gnu11; 249 | GCC_NO_COMMON_BLOCKS = YES; 250 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 251 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 252 | GCC_WARN_UNDECLARED_SELECTOR = YES; 253 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 254 | GCC_WARN_UNUSED_FUNCTION = YES; 255 | GCC_WARN_UNUSED_VARIABLE = YES; 256 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 257 | MTL_ENABLE_DEBUG_INFO = NO; 258 | MTL_FAST_MATH = YES; 259 | SDKROOT = iphoneos; 260 | SWIFT_COMPILATION_MODE = wholemodule; 261 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 262 | VALIDATE_PRODUCT = YES; 263 | }; 264 | name = Release; 265 | }; 266 | 8B5D499F2189CBFC008E458C /* Debug */ = { 267 | isa = XCBuildConfiguration; 268 | buildSettings = { 269 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 270 | CODE_SIGN_STYLE = Automatic; 271 | DEVELOPMENT_TEAM = 5C2XD9H2JS; 272 | INFOPLIST_FILE = GenericTableView/Info.plist; 273 | LD_RUNPATH_SEARCH_PATHS = ( 274 | "$(inherited)", 275 | "@executable_path/Frameworks", 276 | ); 277 | PRODUCT_BUNDLE_IDENTIFIER = com.alfianlosari.GenericTableView; 278 | PRODUCT_NAME = "$(TARGET_NAME)"; 279 | SWIFT_VERSION = 4.2; 280 | TARGETED_DEVICE_FAMILY = 1; 281 | }; 282 | name = Debug; 283 | }; 284 | 8B5D49A02189CBFC008E458C /* Release */ = { 285 | isa = XCBuildConfiguration; 286 | buildSettings = { 287 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 288 | CODE_SIGN_STYLE = Automatic; 289 | DEVELOPMENT_TEAM = 5C2XD9H2JS; 290 | INFOPLIST_FILE = GenericTableView/Info.plist; 291 | LD_RUNPATH_SEARCH_PATHS = ( 292 | "$(inherited)", 293 | "@executable_path/Frameworks", 294 | ); 295 | PRODUCT_BUNDLE_IDENTIFIER = com.alfianlosari.GenericTableView; 296 | PRODUCT_NAME = "$(TARGET_NAME)"; 297 | SWIFT_VERSION = 4.2; 298 | TARGETED_DEVICE_FAMILY = 1; 299 | }; 300 | name = Release; 301 | }; 302 | /* End XCBuildConfiguration section */ 303 | 304 | /* Begin XCConfigurationList section */ 305 | 8B5D49872189CBFA008E458C /* Build configuration list for PBXProject "GenericTableView" */ = { 306 | isa = XCConfigurationList; 307 | buildConfigurations = ( 308 | 8B5D499C2189CBFC008E458C /* Debug */, 309 | 8B5D499D2189CBFC008E458C /* Release */, 310 | ); 311 | defaultConfigurationIsVisible = 0; 312 | defaultConfigurationName = Release; 313 | }; 314 | 8B5D499E2189CBFC008E458C /* Build configuration list for PBXNativeTarget "GenericTableView" */ = { 315 | isa = XCConfigurationList; 316 | buildConfigurations = ( 317 | 8B5D499F2189CBFC008E458C /* Debug */, 318 | 8B5D49A02189CBFC008E458C /* Release */, 319 | ); 320 | defaultConfigurationIsVisible = 0; 321 | defaultConfigurationName = Release; 322 | }; 323 | /* End XCConfigurationList section */ 324 | }; 325 | rootObject = 8B5D49842189CBFA008E458C /* Project object */; 326 | } 327 | -------------------------------------------------------------------------------- /GenericTableView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /GenericTableView.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /GenericTableView.xcodeproj/xcuserdata/alfianlosari.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | GenericTableView.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /GenericTableView/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // GenericTableView 4 | // 5 | // Created by Alfian Losari on 31/10/18. 6 | // Copyright © 2018 alfianlosari. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | 18 | let personsVC = GenericTableViewController(items: Person.stubPerson, configure: { (cell: UITableViewCell, person) in 19 | cell.textLabel?.text = person.name 20 | }) { (person) in 21 | print(person.name) 22 | } 23 | personsVC.title = "Persons" 24 | 25 | let filmsVC = GenericTableViewController(items: Film.stubFilms, configure: { (cell: SubtitleTableViewCell, film) in 26 | cell.textLabel?.text = film.title 27 | cell.detailTextLabel?.text = "\(film.releaseYear)" 28 | }) { (film) in 29 | print(film.title) 30 | } 31 | filmsVC.title = "Films" 32 | 33 | let tabVC = UITabBarController(nibName: nil, bundle: nil) 34 | tabVC.setViewControllers([ 35 | UINavigationController(rootViewController: personsVC), 36 | UINavigationController(rootViewController: filmsVC) 37 | ], animated: false) 38 | 39 | window = UIWindow(frame: UIScreen.main.bounds) 40 | window?.rootViewController = tabVC 41 | window?.makeKeyAndVisible() 42 | 43 | return true 44 | } 45 | 46 | 47 | } 48 | 49 | -------------------------------------------------------------------------------- /GenericTableView/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /GenericTableView/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /GenericTableView/Cell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Cell.swift 3 | // GenericTableView 4 | // 5 | // Created by Alfian Losari on 01/11/18. 6 | // Copyright © 2018 alfianlosari. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SubtitleTableViewCell: UITableViewCell { 12 | 13 | override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 14 | super.init(style: .subtitle, reuseIdentifier: nil) 15 | } 16 | 17 | required init?(coder aDecoder: NSCoder) { 18 | fatalError("init(coder:) has not been implemented") 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /GenericTableView/GenericTableViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GenericTableViewController.swift 3 | // GenericTableView 4 | // 5 | // Created by Alfian Losari on 31/10/18. 6 | // Copyright © 2018 alfianlosari. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class GenericTableViewController: UITableViewController { 12 | 13 | var items: [T] 14 | var configure: (Cell, T) -> Void 15 | var selectHandler: (T) -> Void 16 | 17 | required init?(coder aDecoder: NSCoder) { 18 | fatalError("init(coder:) has not been implemented") 19 | } 20 | 21 | init(items: [T], configure: @escaping (Cell, T) -> Void, selectHandler: @escaping (T) -> Void) { 22 | self.items = items 23 | self.configure = configure 24 | self.selectHandler = selectHandler 25 | super.init(style: .plain) 26 | self.tableView.register(Cell.self, forCellReuseIdentifier: "Cell") 27 | } 28 | 29 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 30 | return items.count 31 | } 32 | 33 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 34 | let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! Cell 35 | let item = items[indexPath.row] 36 | configure(cell, item) 37 | return cell 38 | } 39 | 40 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 41 | tableView.deselectRow(at: indexPath, animated: true) 42 | let item = items[indexPath.row] 43 | selectHandler(item) 44 | } 45 | 46 | } 47 | 48 | -------------------------------------------------------------------------------- /GenericTableView/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LauncScreen 25 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /GenericTableView/LauncScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /GenericTableView/Model.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Model.swift 3 | // GenericTableView 4 | // 5 | // Created by Alfian Losari on 01/11/18. 6 | // Copyright © 2018 alfianlosari. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | struct Person { 12 | let name: String 13 | 14 | static var stubPerson: [Person] { 15 | return [Person(name: "Mark Hamill"), 16 | Person(name: "Harrison Ford"), 17 | Person(name: "Carrie Fisher"), 18 | Person(name: "Hayden Christensen"), 19 | Person(name: "Ewan McGregor"), 20 | Person(name: "Natalie Portman"), 21 | Person(name: "Liam Neeson") 22 | ] 23 | 24 | } 25 | } 26 | 27 | struct Film { 28 | let title: String 29 | let releaseYear: Int 30 | 31 | static var stubFilms: [Film] { 32 | return [Film(title: "Star Wars: A New Hope", releaseYear: 1978), 33 | Film(title: "Star Wars: Empire Strikes Back", releaseYear: 1982), 34 | Film(title: "Star Wars: Return of the Jedi", releaseYear: 1984), 35 | Film(title: "Star Wars: The Phantom Menace", releaseYear: 1999), 36 | Film(title: "Star Wars: Clone Wars", releaseYear: 2003), 37 | Film(title: "Star Wars: Revenge of the Sith", releaseYear: 2005)] 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Generic UITableViewController 2 | 3 | ## Description 4 | Implementation of Abstract TableViewController that can accept different type of data, cell configuration, cell selected handler using Swift Generic 5 | --------------------------------------------------------------------------------