├── .gitignore ├── LICENSE ├── NSTableView+Sections.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── marcinkrzyzanowski.xcuserdatad │ └── xcschemes │ ├── NSTableView+Sections.xcscheme │ └── xcschememanagement.plist ├── NSTableView+Sections ├── AppDelegate.swift ├── Base.lproj │ └── Main.storyboard ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist └── ViewController.swift └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io 2 | 3 | ### Xcode ### 4 | build/ 5 | *.pbxuser 6 | !default.pbxuser 7 | *.mode1v3 8 | !default.mode1v3 9 | *.mode2v3 10 | !default.mode2v3 11 | *.perspectivev3 12 | !default.perspectivev3 13 | xcuserdata 14 | *.xccheckout 15 | *.moved-aside 16 | DerivedData 17 | *.xcuserstate 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Marcin Krzyzanowski 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /NSTableView+Sections.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 75DF38F61B183E76006C7C5D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DF38F51B183E76006C7C5D /* AppDelegate.swift */; }; 11 | 75DF38F81B183E76006C7C5D /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75DF38F71B183E76006C7C5D /* ViewController.swift */; }; 12 | 75DF38FA1B183E76006C7C5D /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 75DF38F91B183E76006C7C5D /* Images.xcassets */; }; 13 | 75DF38FD1B183E76006C7C5D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 75DF38FB1B183E76006C7C5D /* Main.storyboard */; }; 14 | /* End PBXBuildFile section */ 15 | 16 | /* Begin PBXFileReference section */ 17 | 75DF38F01B183E76006C7C5D /* NSTableView+Sections.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "NSTableView+Sections.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 18 | 75DF38F41B183E76006C7C5D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 19 | 75DF38F51B183E76006C7C5D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 20 | 75DF38F71B183E76006C7C5D /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 21 | 75DF38F91B183E76006C7C5D /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 22 | 75DF38FC1B183E76006C7C5D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 23 | /* End PBXFileReference section */ 24 | 25 | /* Begin PBXFrameworksBuildPhase section */ 26 | 75DF38ED1B183E75006C7C5D /* Frameworks */ = { 27 | isa = PBXFrameworksBuildPhase; 28 | buildActionMask = 2147483647; 29 | files = ( 30 | ); 31 | runOnlyForDeploymentPostprocessing = 0; 32 | }; 33 | /* End PBXFrameworksBuildPhase section */ 34 | 35 | /* Begin PBXGroup section */ 36 | 75DF38E71B183E75006C7C5D = { 37 | isa = PBXGroup; 38 | children = ( 39 | 75DF38F21B183E76006C7C5D /* NSTableView+Sections */, 40 | 75DF38F11B183E76006C7C5D /* Products */, 41 | ); 42 | sourceTree = ""; 43 | }; 44 | 75DF38F11B183E76006C7C5D /* Products */ = { 45 | isa = PBXGroup; 46 | children = ( 47 | 75DF38F01B183E76006C7C5D /* NSTableView+Sections.app */, 48 | ); 49 | name = Products; 50 | sourceTree = ""; 51 | }; 52 | 75DF38F21B183E76006C7C5D /* NSTableView+Sections */ = { 53 | isa = PBXGroup; 54 | children = ( 55 | 75DF38F71B183E76006C7C5D /* ViewController.swift */, 56 | 75DF38FB1B183E76006C7C5D /* Main.storyboard */, 57 | 75DF38F31B183E76006C7C5D /* Supporting Files */, 58 | ); 59 | path = "NSTableView+Sections"; 60 | sourceTree = ""; 61 | }; 62 | 75DF38F31B183E76006C7C5D /* Supporting Files */ = { 63 | isa = PBXGroup; 64 | children = ( 65 | 75DF38F51B183E76006C7C5D /* AppDelegate.swift */, 66 | 75DF38F91B183E76006C7C5D /* Images.xcassets */, 67 | 75DF38F41B183E76006C7C5D /* Info.plist */, 68 | ); 69 | name = "Supporting Files"; 70 | sourceTree = ""; 71 | }; 72 | /* End PBXGroup section */ 73 | 74 | /* Begin PBXNativeTarget section */ 75 | 75DF38EF1B183E75006C7C5D /* NSTableView+Sections */ = { 76 | isa = PBXNativeTarget; 77 | buildConfigurationList = 75DF390C1B183E76006C7C5D /* Build configuration list for PBXNativeTarget "NSTableView+Sections" */; 78 | buildPhases = ( 79 | 75DF38EC1B183E75006C7C5D /* Sources */, 80 | 75DF38ED1B183E75006C7C5D /* Frameworks */, 81 | 75DF38EE1B183E75006C7C5D /* Resources */, 82 | ); 83 | buildRules = ( 84 | ); 85 | dependencies = ( 86 | ); 87 | name = "NSTableView+Sections"; 88 | productName = "NSTableView+Sections"; 89 | productReference = 75DF38F01B183E76006C7C5D /* NSTableView+Sections.app */; 90 | productType = "com.apple.product-type.application"; 91 | }; 92 | /* End PBXNativeTarget section */ 93 | 94 | /* Begin PBXProject section */ 95 | 75DF38E81B183E75006C7C5D /* Project object */ = { 96 | isa = PBXProject; 97 | attributes = { 98 | LastUpgradeCheck = 1020; 99 | ORGANIZATIONNAME = "Marcin Krzyzanowski"; 100 | TargetAttributes = { 101 | 75DF38EF1B183E75006C7C5D = { 102 | CreatedOnToolsVersion = 6.3.2; 103 | }; 104 | }; 105 | }; 106 | buildConfigurationList = 75DF38EB1B183E75006C7C5D /* Build configuration list for PBXProject "NSTableView+Sections" */; 107 | compatibilityVersion = "Xcode 3.2"; 108 | developmentRegion = en; 109 | hasScannedForEncodings = 0; 110 | knownRegions = ( 111 | en, 112 | Base, 113 | ); 114 | mainGroup = 75DF38E71B183E75006C7C5D; 115 | productRefGroup = 75DF38F11B183E76006C7C5D /* Products */; 116 | projectDirPath = ""; 117 | projectRoot = ""; 118 | targets = ( 119 | 75DF38EF1B183E75006C7C5D /* NSTableView+Sections */, 120 | ); 121 | }; 122 | /* End PBXProject section */ 123 | 124 | /* Begin PBXResourcesBuildPhase section */ 125 | 75DF38EE1B183E75006C7C5D /* Resources */ = { 126 | isa = PBXResourcesBuildPhase; 127 | buildActionMask = 2147483647; 128 | files = ( 129 | 75DF38FA1B183E76006C7C5D /* Images.xcassets in Resources */, 130 | 75DF38FD1B183E76006C7C5D /* Main.storyboard in Resources */, 131 | ); 132 | runOnlyForDeploymentPostprocessing = 0; 133 | }; 134 | /* End PBXResourcesBuildPhase section */ 135 | 136 | /* Begin PBXSourcesBuildPhase section */ 137 | 75DF38EC1B183E75006C7C5D /* Sources */ = { 138 | isa = PBXSourcesBuildPhase; 139 | buildActionMask = 2147483647; 140 | files = ( 141 | 75DF38F81B183E76006C7C5D /* ViewController.swift in Sources */, 142 | 75DF38F61B183E76006C7C5D /* AppDelegate.swift in Sources */, 143 | ); 144 | runOnlyForDeploymentPostprocessing = 0; 145 | }; 146 | /* End PBXSourcesBuildPhase section */ 147 | 148 | /* Begin PBXVariantGroup section */ 149 | 75DF38FB1B183E76006C7C5D /* Main.storyboard */ = { 150 | isa = PBXVariantGroup; 151 | children = ( 152 | 75DF38FC1B183E76006C7C5D /* Base */, 153 | ); 154 | name = Main.storyboard; 155 | sourceTree = ""; 156 | }; 157 | /* End PBXVariantGroup section */ 158 | 159 | /* Begin XCBuildConfiguration section */ 160 | 75DF390A1B183E76006C7C5D /* Debug */ = { 161 | isa = XCBuildConfiguration; 162 | buildSettings = { 163 | ALWAYS_SEARCH_USER_PATHS = NO; 164 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 165 | CLANG_CXX_LIBRARY = "libc++"; 166 | CLANG_ENABLE_MODULES = YES; 167 | CLANG_ENABLE_OBJC_ARC = YES; 168 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 169 | CLANG_WARN_BOOL_CONVERSION = YES; 170 | CLANG_WARN_COMMA = YES; 171 | CLANG_WARN_CONSTANT_CONVERSION = YES; 172 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 173 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 174 | CLANG_WARN_EMPTY_BODY = YES; 175 | CLANG_WARN_ENUM_CONVERSION = YES; 176 | CLANG_WARN_INFINITE_RECURSION = YES; 177 | CLANG_WARN_INT_CONVERSION = YES; 178 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 179 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 180 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 181 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 182 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 183 | CLANG_WARN_STRICT_PROTOTYPES = YES; 184 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 185 | CLANG_WARN_UNREACHABLE_CODE = YES; 186 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 187 | CODE_SIGN_IDENTITY = "-"; 188 | COPY_PHASE_STRIP = NO; 189 | DEBUG_INFORMATION_FORMAT = dwarf; 190 | ENABLE_STRICT_OBJC_MSGSEND = YES; 191 | ENABLE_TESTABILITY = YES; 192 | GCC_C_LANGUAGE_STANDARD = gnu99; 193 | GCC_DYNAMIC_NO_PIC = NO; 194 | GCC_NO_COMMON_BLOCKS = YES; 195 | GCC_OPTIMIZATION_LEVEL = 0; 196 | GCC_PREPROCESSOR_DEFINITIONS = ( 197 | "DEBUG=1", 198 | "$(inherited)", 199 | ); 200 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 201 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 202 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 203 | GCC_WARN_UNDECLARED_SELECTOR = YES; 204 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 205 | GCC_WARN_UNUSED_FUNCTION = YES; 206 | GCC_WARN_UNUSED_VARIABLE = YES; 207 | MACOSX_DEPLOYMENT_TARGET = 10.10; 208 | MTL_ENABLE_DEBUG_INFO = YES; 209 | ONLY_ACTIVE_ARCH = YES; 210 | SDKROOT = macosx; 211 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 212 | SWIFT_VERSION = 5.0; 213 | }; 214 | name = Debug; 215 | }; 216 | 75DF390B1B183E76006C7C5D /* Release */ = { 217 | isa = XCBuildConfiguration; 218 | buildSettings = { 219 | ALWAYS_SEARCH_USER_PATHS = NO; 220 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 221 | CLANG_CXX_LIBRARY = "libc++"; 222 | CLANG_ENABLE_MODULES = YES; 223 | CLANG_ENABLE_OBJC_ARC = YES; 224 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 225 | CLANG_WARN_BOOL_CONVERSION = YES; 226 | CLANG_WARN_COMMA = YES; 227 | CLANG_WARN_CONSTANT_CONVERSION = YES; 228 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 229 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 230 | CLANG_WARN_EMPTY_BODY = YES; 231 | CLANG_WARN_ENUM_CONVERSION = YES; 232 | CLANG_WARN_INFINITE_RECURSION = YES; 233 | CLANG_WARN_INT_CONVERSION = YES; 234 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 235 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 236 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 237 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 238 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 239 | CLANG_WARN_STRICT_PROTOTYPES = YES; 240 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 241 | CLANG_WARN_UNREACHABLE_CODE = YES; 242 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 243 | CODE_SIGN_IDENTITY = "-"; 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 = gnu99; 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 | MACOSX_DEPLOYMENT_TARGET = 10.10; 257 | MTL_ENABLE_DEBUG_INFO = NO; 258 | SDKROOT = macosx; 259 | SWIFT_COMPILATION_MODE = wholemodule; 260 | SWIFT_VERSION = 5.0; 261 | }; 262 | name = Release; 263 | }; 264 | 75DF390D1B183E76006C7C5D /* Debug */ = { 265 | isa = XCBuildConfiguration; 266 | buildSettings = { 267 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 268 | COMBINE_HIDPI_IMAGES = YES; 269 | INFOPLIST_FILE = "NSTableView+Sections/Info.plist"; 270 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 271 | PRODUCT_BUNDLE_IDENTIFIER = "com.mailcloud.$(PRODUCT_NAME:rfc1034identifier)"; 272 | PRODUCT_NAME = "$(TARGET_NAME)"; 273 | }; 274 | name = Debug; 275 | }; 276 | 75DF390E1B183E76006C7C5D /* Release */ = { 277 | isa = XCBuildConfiguration; 278 | buildSettings = { 279 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 280 | COMBINE_HIDPI_IMAGES = YES; 281 | INFOPLIST_FILE = "NSTableView+Sections/Info.plist"; 282 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 283 | PRODUCT_BUNDLE_IDENTIFIER = "com.mailcloud.$(PRODUCT_NAME:rfc1034identifier)"; 284 | PRODUCT_NAME = "$(TARGET_NAME)"; 285 | }; 286 | name = Release; 287 | }; 288 | /* End XCBuildConfiguration section */ 289 | 290 | /* Begin XCConfigurationList section */ 291 | 75DF38EB1B183E75006C7C5D /* Build configuration list for PBXProject "NSTableView+Sections" */ = { 292 | isa = XCConfigurationList; 293 | buildConfigurations = ( 294 | 75DF390A1B183E76006C7C5D /* Debug */, 295 | 75DF390B1B183E76006C7C5D /* Release */, 296 | ); 297 | defaultConfigurationIsVisible = 0; 298 | defaultConfigurationName = Release; 299 | }; 300 | 75DF390C1B183E76006C7C5D /* Build configuration list for PBXNativeTarget "NSTableView+Sections" */ = { 301 | isa = XCConfigurationList; 302 | buildConfigurations = ( 303 | 75DF390D1B183E76006C7C5D /* Debug */, 304 | 75DF390E1B183E76006C7C5D /* Release */, 305 | ); 306 | defaultConfigurationIsVisible = 0; 307 | defaultConfigurationName = Release; 308 | }; 309 | /* End XCConfigurationList section */ 310 | }; 311 | rootObject = 75DF38E81B183E75006C7C5D /* Project object */; 312 | } 313 | -------------------------------------------------------------------------------- /NSTableView+Sections.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NSTableView+Sections.xcodeproj/xcuserdata/marcinkrzyzanowski.xcuserdatad/xcschemes/NSTableView+Sections.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 77 | 83 | 84 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /NSTableView+Sections.xcodeproj/xcuserdata/marcinkrzyzanowski.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | NSTableView+Sections.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 75DF38EF1B183E75006C7C5D 16 | 17 | primary 18 | 19 | 20 | 75DF39011B183E76006C7C5D 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /NSTableView+Sections/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // NSTableView+Sections 4 | // 5 | // Created by Marcin Krzyzanowski on 29/05/15. 6 | // Copyright (c) 2015 Marcin Krzyzanowski. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | @NSApplicationMain 12 | class AppDelegate: NSObject, NSApplicationDelegate { 13 | 14 | 15 | 16 | func applicationDidFinishLaunching(aNotification: NSNotification) { 17 | // Insert code here to initialize your application 18 | } 19 | 20 | func applicationWillTerminate(aNotification: NSNotification) { 21 | // Insert code here to tear down your application 22 | } 23 | 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /NSTableView+Sections/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | Default 512 | 513 | 514 | 515 | 516 | 517 | 518 | Left to Right 519 | 520 | 521 | 522 | 523 | 524 | 525 | Right to Left 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | Default 537 | 538 | 539 | 540 | 541 | 542 | 543 | Left to Right 544 | 545 | 546 | 547 | 548 | 549 | 550 | Right to Left 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 762 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | -------------------------------------------------------------------------------- /NSTableView+Sections/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /NSTableView+Sections/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSHumanReadableCopyright 28 | Copyright © 2015 Marcin Krzyzanowski. All rights reserved. 29 | NSMainStoryboardFile 30 | Main 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /NSTableView+Sections/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // NSTableView+Sections 4 | // 5 | // Created by Marcin Krzyzanowski on 29/05/15. 6 | // Copyright (c) 2015 Marcin Krzyzanowski. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | class ViewController: NSViewController, NSTableViewDelegate { 12 | 13 | enum Section: Int, CaseIterable { 14 | case people = 0 15 | case group 16 | 17 | var name:String { 18 | switch self { 19 | case .people: 20 | return "PEOPLE" 21 | case .group: 22 | return "GROUP" 23 | } 24 | } 25 | } 26 | 27 | @IBOutlet var tableView: NSTableView! 28 | private let people:[String] = ["Frank","Monica","Natalie","Alice"] 29 | private let groups:[String] = ["Engineers","Teachers","Bookkeepers"] 30 | 31 | override func viewDidLoad() { 32 | super.viewDidLoad() 33 | tableView.reloadData() 34 | } 35 | 36 | //MARK: - NSTableViewDelegate 37 | 38 | func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? { 39 | let cellView = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "CellView"), owner: self) as! NSTableCellView 40 | 41 | if let dataSource = tableView.dataSource as? NSTableViewSectionDataSource { 42 | let (section, sectionRow) = dataSource.tableView(tableView: tableView, sectionForRow: row) 43 | 44 | if let headerView = self.tableView(tableView: tableView, viewForHeaderInSection: section) as? NSTableCellView, sectionRow == 0 { 45 | if let value = tableView.dataSource?.tableView!(tableView, objectValueFor: tableColumn, row: row) as? String { 46 | headerView.textField?.stringValue = value 47 | } 48 | return headerView 49 | } 50 | } 51 | 52 | if let value = tableView.dataSource?.tableView!(tableView, objectValueFor: tableColumn, row: row) as? String { 53 | cellView.textField?.stringValue = value 54 | } 55 | return cellView 56 | } 57 | 58 | func tableView(_ tableView: NSTableView, shouldSelectRow row: Int) -> Bool { 59 | if let dataSource = tableView.dataSource as? NSTableViewSectionDataSource { 60 | let (_, sectionRow) = dataSource.tableView(tableView: tableView, sectionForRow: row) 61 | 62 | if sectionRow == 0 { 63 | return false 64 | } 65 | 66 | return true 67 | } 68 | return false 69 | } 70 | } 71 | 72 | //MARK: - NSTableViewSectionDelegate 73 | 74 | protocol NSTableViewSectionDelegate: NSTableViewDelegate { 75 | func tableView(tableView: NSTableView, viewForHeaderInSection section: Int) -> NSView? 76 | } 77 | 78 | extension ViewController: NSTableViewSectionDelegate { 79 | func tableView(tableView: NSTableView, viewForHeaderInSection section: Int) -> NSView? { 80 | switch (section) { 81 | case Section.people.rawValue, Section.group.rawValue: 82 | let sectionView = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "SectionView"), owner: self) as! NSTableCellView 83 | return sectionView 84 | default: 85 | break 86 | } 87 | return nil 88 | } 89 | } 90 | 91 | //MARK: - NSTableViewSectionDataSource 92 | 93 | protocol NSTableViewSectionDataSource: NSTableViewDataSource { 94 | func numberOfSectionsInTableView(tableView: NSTableView) -> Int 95 | func tableView(tableView: NSTableView, numberOfRowsInSection section: Int) -> Int 96 | func tableView(tableView: NSTableView, sectionForRow row: Int) -> (section: Int, row: Int) 97 | } 98 | 99 | extension ViewController: NSTableViewSectionDataSource { 100 | 101 | func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? { 102 | if let dataSource = tableView.dataSource as? NSTableViewSectionDataSource { 103 | var (section, sectionRow) = dataSource.tableView(tableView: tableView, sectionForRow: row) 104 | 105 | if self.tableView(tableView: tableView, viewForHeaderInSection: section) != nil { 106 | if sectionRow == 0 { 107 | return Section(rawValue: section)?.name as AnyObject? 108 | } else { 109 | sectionRow -= 1 110 | } 111 | } 112 | 113 | switch (section) { 114 | case Section.people.rawValue: 115 | return people[sectionRow] as AnyObject 116 | case Section.group.rawValue: 117 | return groups[sectionRow] as AnyObject 118 | default: 119 | return 0 as AnyObject 120 | } 121 | } 122 | return nil 123 | } 124 | 125 | func numberOfRows(in tableView: NSTableView) -> Int { 126 | var total = 0 127 | 128 | if let dataSource = tableView.dataSource as? NSTableViewSectionDataSource { 129 | for section in 0.. Int { 138 | return Section.allCases.count 139 | } 140 | 141 | func tableView(tableView: NSTableView, numberOfRowsInSection section: Int) -> Int { 142 | var count = 0 143 | 144 | if self.tableView(tableView: tableView, viewForHeaderInSection: section) != nil { 145 | count += 1 146 | } 147 | 148 | switch (section) { 149 | case Section.people.rawValue: 150 | count += people.count 151 | case Section.group.rawValue: 152 | count += groups.count 153 | default: 154 | return 0 155 | } 156 | 157 | return count 158 | } 159 | 160 | func tableView(tableView: NSTableView, sectionForRow row: Int) -> (section: Int, row: Int) { 161 | if let dataSource = tableView.dataSource as? NSTableViewSectionDataSource { 162 | let numberOfSections = dataSource.numberOfSectionsInTableView(tableView: tableView) 163 | var counts = [Int](repeating: 0, count: numberOfSections) 164 | 165 | for section in 0.. (section: Int?, row: Int?) { 178 | var c = counts[0] 179 | for section in 0.. 0) { 181 | c = c + counts[section] 182 | } 183 | if (row >= c - counts[section]) && row < c { 184 | return (section: section, row: row - (c - counts[section])) 185 | } 186 | } 187 | return (section: nil, row: nil) 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NSTableView-Sections 2 | NSTableView with sections (similar to UITableView). 3 | 4 | Demonstration of implementation of sections for NSTableView component. 5 | 6 | ![](https://cloud.githubusercontent.com/assets/758033/7903468/adb5b78c-07dd-11e5-8c9d-3d8775f71913.gif) 7 | 8 | # Author 9 | 10 | [Marcin Krzyżanowski](http://krzyzanowskim.com) 11 | 12 | Twitter: [@krzyzanowskim](http://twitter.com/krzyzanowskim) --------------------------------------------------------------------------------