├── .gitignore ├── LICENSE ├── NSOutlineViewInSwift ├── NSOutlineViewInSwift.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── NSOutlineViewInSwift │ ├── AppDelegate.swift │ ├── Base.lproj │ │ └── Main.storyboard │ ├── FileSystemItem.swift │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ └── ViewController.swift └── NSOutlineViewInSwiftTests │ ├── Info.plist │ └── NSOutlineViewInSwiftTests.swift ├── NSOutlineViewUsingViewMode ├── NSOutlineViewUsingViewMode.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── NSOutlineViewUsingViewMode │ ├── AppDelegate.swift │ ├── Base.lproj │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ └── ViewController.swift └── NSOutlineViewUsingViewModeTests │ ├── Info.plist │ └── NSOutlineViewUsingViewModeTests.swift ├── NSSourceListInSwift ├── Artwork │ ├── Artboard 1.pdf │ ├── Artboard 2.pdf │ ├── Artboard 3.pdf │ ├── Artboard 4.pdf │ └── Artboard 5.pdf ├── Icons.sketch ├── NSSourceListInSwift.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── NSSourceListInSwift │ ├── AppDelegate.swift │ ├── Attributions.rtf │ ├── Base.lproj │ │ └── Main.storyboard │ ├── Images.xcassets │ │ ├── Antigonia.imageset │ │ │ ├── Artboard 5.pdf │ │ │ └── Contents.json │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Leopard.imageset │ │ │ ├── Artboard 1.pdf │ │ │ └── Contents.json │ │ ├── Lion.imageset │ │ │ ├── Artboard 2.pdf │ │ │ └── Contents.json │ │ ├── Panthera.imageset │ │ │ ├── Artboard 4.pdf │ │ │ └── Contents.json │ │ └── Tiger.imageset │ │ │ ├── Artboard 3.pdf │ │ │ └── Contents.json │ ├── Info.plist │ ├── Model.swift │ └── ViewController.swift └── NSSourceListInSwiftTests │ ├── Info.plist │ └── NSSourceListInSwiftTests.swift └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Daniel Pink 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 | -------------------------------------------------------------------------------- /NSOutlineViewInSwift/NSOutlineViewInSwift.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | E60F19031A2D25CC0094D994 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E60F19021A2D25CC0094D994 /* AppDelegate.swift */; }; 11 | E60F19051A2D25CC0094D994 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E60F19041A2D25CC0094D994 /* ViewController.swift */; }; 12 | E60F19071A2D25CC0094D994 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E60F19061A2D25CC0094D994 /* Images.xcassets */; }; 13 | E60F190A1A2D25CC0094D994 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E60F19081A2D25CC0094D994 /* Main.storyboard */; }; 14 | E60F19161A2D25CC0094D994 /* NSOutlineViewInSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E60F19151A2D25CC0094D994 /* NSOutlineViewInSwiftTests.swift */; }; 15 | E60F19201A2D29270094D994 /* FileSystemItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = E60F191F1A2D29270094D994 /* FileSystemItem.swift */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXContainerItemProxy section */ 19 | E60F19101A2D25CC0094D994 /* PBXContainerItemProxy */ = { 20 | isa = PBXContainerItemProxy; 21 | containerPortal = E60F18F51A2D25CC0094D994 /* Project object */; 22 | proxyType = 1; 23 | remoteGlobalIDString = E60F18FC1A2D25CC0094D994; 24 | remoteInfo = NSOutlineViewInSwift; 25 | }; 26 | /* End PBXContainerItemProxy section */ 27 | 28 | /* Begin PBXFileReference section */ 29 | E60F18FD1A2D25CC0094D994 /* NSOutlineViewInSwift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NSOutlineViewInSwift.app; sourceTree = BUILT_PRODUCTS_DIR; }; 30 | E60F19011A2D25CC0094D994 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 31 | E60F19021A2D25CC0094D994 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 32 | E60F19041A2D25CC0094D994 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 33 | E60F19061A2D25CC0094D994 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 34 | E60F19091A2D25CC0094D994 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 35 | E60F190F1A2D25CC0094D994 /* NSOutlineViewInSwiftTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NSOutlineViewInSwiftTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 36 | E60F19141A2D25CC0094D994 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 37 | E60F19151A2D25CC0094D994 /* NSOutlineViewInSwiftTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSOutlineViewInSwiftTests.swift; sourceTree = ""; }; 38 | E60F191F1A2D29270094D994 /* FileSystemItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileSystemItem.swift; sourceTree = ""; }; 39 | /* End PBXFileReference section */ 40 | 41 | /* Begin PBXFrameworksBuildPhase section */ 42 | E60F18FA1A2D25CC0094D994 /* Frameworks */ = { 43 | isa = PBXFrameworksBuildPhase; 44 | buildActionMask = 2147483647; 45 | files = ( 46 | ); 47 | runOnlyForDeploymentPostprocessing = 0; 48 | }; 49 | E60F190C1A2D25CC0094D994 /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | /* End PBXFrameworksBuildPhase section */ 57 | 58 | /* Begin PBXGroup section */ 59 | E60F18F41A2D25CC0094D994 = { 60 | isa = PBXGroup; 61 | children = ( 62 | E60F18FF1A2D25CC0094D994 /* NSOutlineViewInSwift */, 63 | E60F19121A2D25CC0094D994 /* NSOutlineViewInSwiftTests */, 64 | E60F18FE1A2D25CC0094D994 /* Products */, 65 | ); 66 | sourceTree = ""; 67 | }; 68 | E60F18FE1A2D25CC0094D994 /* Products */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | E60F18FD1A2D25CC0094D994 /* NSOutlineViewInSwift.app */, 72 | E60F190F1A2D25CC0094D994 /* NSOutlineViewInSwiftTests.xctest */, 73 | ); 74 | name = Products; 75 | sourceTree = ""; 76 | }; 77 | E60F18FF1A2D25CC0094D994 /* NSOutlineViewInSwift */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | E60F19021A2D25CC0094D994 /* AppDelegate.swift */, 81 | E60F19041A2D25CC0094D994 /* ViewController.swift */, 82 | E60F191F1A2D29270094D994 /* FileSystemItem.swift */, 83 | E60F19061A2D25CC0094D994 /* Images.xcassets */, 84 | E60F19081A2D25CC0094D994 /* Main.storyboard */, 85 | E60F19001A2D25CC0094D994 /* Supporting Files */, 86 | ); 87 | path = NSOutlineViewInSwift; 88 | sourceTree = ""; 89 | }; 90 | E60F19001A2D25CC0094D994 /* Supporting Files */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | E60F19011A2D25CC0094D994 /* Info.plist */, 94 | ); 95 | name = "Supporting Files"; 96 | sourceTree = ""; 97 | }; 98 | E60F19121A2D25CC0094D994 /* NSOutlineViewInSwiftTests */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | E60F19151A2D25CC0094D994 /* NSOutlineViewInSwiftTests.swift */, 102 | E60F19131A2D25CC0094D994 /* Supporting Files */, 103 | ); 104 | path = NSOutlineViewInSwiftTests; 105 | sourceTree = ""; 106 | }; 107 | E60F19131A2D25CC0094D994 /* Supporting Files */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | E60F19141A2D25CC0094D994 /* Info.plist */, 111 | ); 112 | name = "Supporting Files"; 113 | sourceTree = ""; 114 | }; 115 | /* End PBXGroup section */ 116 | 117 | /* Begin PBXNativeTarget section */ 118 | E60F18FC1A2D25CC0094D994 /* NSOutlineViewInSwift */ = { 119 | isa = PBXNativeTarget; 120 | buildConfigurationList = E60F19191A2D25CC0094D994 /* Build configuration list for PBXNativeTarget "NSOutlineViewInSwift" */; 121 | buildPhases = ( 122 | E60F18F91A2D25CC0094D994 /* Sources */, 123 | E60F18FA1A2D25CC0094D994 /* Frameworks */, 124 | E60F18FB1A2D25CC0094D994 /* Resources */, 125 | ); 126 | buildRules = ( 127 | ); 128 | dependencies = ( 129 | ); 130 | name = NSOutlineViewInSwift; 131 | productName = NSOutlineViewInSwift; 132 | productReference = E60F18FD1A2D25CC0094D994 /* NSOutlineViewInSwift.app */; 133 | productType = "com.apple.product-type.application"; 134 | }; 135 | E60F190E1A2D25CC0094D994 /* NSOutlineViewInSwiftTests */ = { 136 | isa = PBXNativeTarget; 137 | buildConfigurationList = E60F191C1A2D25CC0094D994 /* Build configuration list for PBXNativeTarget "NSOutlineViewInSwiftTests" */; 138 | buildPhases = ( 139 | E60F190B1A2D25CC0094D994 /* Sources */, 140 | E60F190C1A2D25CC0094D994 /* Frameworks */, 141 | E60F190D1A2D25CC0094D994 /* Resources */, 142 | ); 143 | buildRules = ( 144 | ); 145 | dependencies = ( 146 | E60F19111A2D25CC0094D994 /* PBXTargetDependency */, 147 | ); 148 | name = NSOutlineViewInSwiftTests; 149 | productName = NSOutlineViewInSwiftTests; 150 | productReference = E60F190F1A2D25CC0094D994 /* NSOutlineViewInSwiftTests.xctest */; 151 | productType = "com.apple.product-type.bundle.unit-test"; 152 | }; 153 | /* End PBXNativeTarget section */ 154 | 155 | /* Begin PBXProject section */ 156 | E60F18F51A2D25CC0094D994 /* Project object */ = { 157 | isa = PBXProject; 158 | attributes = { 159 | LastSwiftUpdateCheck = 0700; 160 | LastUpgradeCheck = 0700; 161 | ORGANIZATIONNAME = "Electronic Innovations"; 162 | TargetAttributes = { 163 | E60F18FC1A2D25CC0094D994 = { 164 | CreatedOnToolsVersion = 6.1; 165 | }; 166 | E60F190E1A2D25CC0094D994 = { 167 | CreatedOnToolsVersion = 6.1; 168 | TestTargetID = E60F18FC1A2D25CC0094D994; 169 | }; 170 | }; 171 | }; 172 | buildConfigurationList = E60F18F81A2D25CC0094D994 /* Build configuration list for PBXProject "NSOutlineViewInSwift" */; 173 | compatibilityVersion = "Xcode 3.2"; 174 | developmentRegion = English; 175 | hasScannedForEncodings = 0; 176 | knownRegions = ( 177 | en, 178 | Base, 179 | ); 180 | mainGroup = E60F18F41A2D25CC0094D994; 181 | productRefGroup = E60F18FE1A2D25CC0094D994 /* Products */; 182 | projectDirPath = ""; 183 | projectRoot = ""; 184 | targets = ( 185 | E60F18FC1A2D25CC0094D994 /* NSOutlineViewInSwift */, 186 | E60F190E1A2D25CC0094D994 /* NSOutlineViewInSwiftTests */, 187 | ); 188 | }; 189 | /* End PBXProject section */ 190 | 191 | /* Begin PBXResourcesBuildPhase section */ 192 | E60F18FB1A2D25CC0094D994 /* Resources */ = { 193 | isa = PBXResourcesBuildPhase; 194 | buildActionMask = 2147483647; 195 | files = ( 196 | E60F19071A2D25CC0094D994 /* Images.xcassets in Resources */, 197 | E60F190A1A2D25CC0094D994 /* Main.storyboard in Resources */, 198 | ); 199 | runOnlyForDeploymentPostprocessing = 0; 200 | }; 201 | E60F190D1A2D25CC0094D994 /* Resources */ = { 202 | isa = PBXResourcesBuildPhase; 203 | buildActionMask = 2147483647; 204 | files = ( 205 | ); 206 | runOnlyForDeploymentPostprocessing = 0; 207 | }; 208 | /* End PBXResourcesBuildPhase section */ 209 | 210 | /* Begin PBXSourcesBuildPhase section */ 211 | E60F18F91A2D25CC0094D994 /* Sources */ = { 212 | isa = PBXSourcesBuildPhase; 213 | buildActionMask = 2147483647; 214 | files = ( 215 | E60F19051A2D25CC0094D994 /* ViewController.swift in Sources */, 216 | E60F19201A2D29270094D994 /* FileSystemItem.swift in Sources */, 217 | E60F19031A2D25CC0094D994 /* AppDelegate.swift in Sources */, 218 | ); 219 | runOnlyForDeploymentPostprocessing = 0; 220 | }; 221 | E60F190B1A2D25CC0094D994 /* Sources */ = { 222 | isa = PBXSourcesBuildPhase; 223 | buildActionMask = 2147483647; 224 | files = ( 225 | E60F19161A2D25CC0094D994 /* NSOutlineViewInSwiftTests.swift in Sources */, 226 | ); 227 | runOnlyForDeploymentPostprocessing = 0; 228 | }; 229 | /* End PBXSourcesBuildPhase section */ 230 | 231 | /* Begin PBXTargetDependency section */ 232 | E60F19111A2D25CC0094D994 /* PBXTargetDependency */ = { 233 | isa = PBXTargetDependency; 234 | target = E60F18FC1A2D25CC0094D994 /* NSOutlineViewInSwift */; 235 | targetProxy = E60F19101A2D25CC0094D994 /* PBXContainerItemProxy */; 236 | }; 237 | /* End PBXTargetDependency section */ 238 | 239 | /* Begin PBXVariantGroup section */ 240 | E60F19081A2D25CC0094D994 /* Main.storyboard */ = { 241 | isa = PBXVariantGroup; 242 | children = ( 243 | E60F19091A2D25CC0094D994 /* Base */, 244 | ); 245 | name = Main.storyboard; 246 | sourceTree = ""; 247 | }; 248 | /* End PBXVariantGroup section */ 249 | 250 | /* Begin XCBuildConfiguration section */ 251 | E60F19171A2D25CC0094D994 /* Debug */ = { 252 | isa = XCBuildConfiguration; 253 | buildSettings = { 254 | ALWAYS_SEARCH_USER_PATHS = NO; 255 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 256 | CLANG_CXX_LIBRARY = "libc++"; 257 | CLANG_ENABLE_MODULES = YES; 258 | CLANG_ENABLE_OBJC_ARC = YES; 259 | CLANG_WARN_BOOL_CONVERSION = YES; 260 | CLANG_WARN_CONSTANT_CONVERSION = YES; 261 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 262 | CLANG_WARN_EMPTY_BODY = YES; 263 | CLANG_WARN_ENUM_CONVERSION = YES; 264 | CLANG_WARN_INT_CONVERSION = YES; 265 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 266 | CLANG_WARN_UNREACHABLE_CODE = YES; 267 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 268 | CODE_SIGN_IDENTITY = "-"; 269 | COPY_PHASE_STRIP = NO; 270 | ENABLE_STRICT_OBJC_MSGSEND = YES; 271 | ENABLE_TESTABILITY = YES; 272 | GCC_C_LANGUAGE_STANDARD = gnu99; 273 | GCC_DYNAMIC_NO_PIC = NO; 274 | GCC_OPTIMIZATION_LEVEL = 0; 275 | GCC_PREPROCESSOR_DEFINITIONS = ( 276 | "DEBUG=1", 277 | "$(inherited)", 278 | ); 279 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 280 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 281 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 282 | GCC_WARN_UNDECLARED_SELECTOR = YES; 283 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 284 | GCC_WARN_UNUSED_FUNCTION = YES; 285 | GCC_WARN_UNUSED_VARIABLE = YES; 286 | MACOSX_DEPLOYMENT_TARGET = 10.10; 287 | MTL_ENABLE_DEBUG_INFO = YES; 288 | ONLY_ACTIVE_ARCH = YES; 289 | SDKROOT = macosx; 290 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 291 | }; 292 | name = Debug; 293 | }; 294 | E60F19181A2D25CC0094D994 /* Release */ = { 295 | isa = XCBuildConfiguration; 296 | buildSettings = { 297 | ALWAYS_SEARCH_USER_PATHS = NO; 298 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 299 | CLANG_CXX_LIBRARY = "libc++"; 300 | CLANG_ENABLE_MODULES = YES; 301 | CLANG_ENABLE_OBJC_ARC = YES; 302 | CLANG_WARN_BOOL_CONVERSION = YES; 303 | CLANG_WARN_CONSTANT_CONVERSION = YES; 304 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 305 | CLANG_WARN_EMPTY_BODY = YES; 306 | CLANG_WARN_ENUM_CONVERSION = YES; 307 | CLANG_WARN_INT_CONVERSION = YES; 308 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 309 | CLANG_WARN_UNREACHABLE_CODE = YES; 310 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 311 | CODE_SIGN_IDENTITY = "-"; 312 | COPY_PHASE_STRIP = YES; 313 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 314 | ENABLE_NS_ASSERTIONS = NO; 315 | ENABLE_STRICT_OBJC_MSGSEND = YES; 316 | GCC_C_LANGUAGE_STANDARD = gnu99; 317 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 318 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 319 | GCC_WARN_UNDECLARED_SELECTOR = YES; 320 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 321 | GCC_WARN_UNUSED_FUNCTION = YES; 322 | GCC_WARN_UNUSED_VARIABLE = YES; 323 | MACOSX_DEPLOYMENT_TARGET = 10.10; 324 | MTL_ENABLE_DEBUG_INFO = NO; 325 | SDKROOT = macosx; 326 | }; 327 | name = Release; 328 | }; 329 | E60F191A1A2D25CC0094D994 /* Debug */ = { 330 | isa = XCBuildConfiguration; 331 | buildSettings = { 332 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 333 | COMBINE_HIDPI_IMAGES = YES; 334 | INFOPLIST_FILE = NSOutlineViewInSwift/Info.plist; 335 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 336 | PRODUCT_BUNDLE_IDENTIFIER = "au.com.electronicinnovations.$(PRODUCT_NAME:rfc1034identifier)"; 337 | PRODUCT_NAME = "$(TARGET_NAME)"; 338 | }; 339 | name = Debug; 340 | }; 341 | E60F191B1A2D25CC0094D994 /* Release */ = { 342 | isa = XCBuildConfiguration; 343 | buildSettings = { 344 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 345 | COMBINE_HIDPI_IMAGES = YES; 346 | INFOPLIST_FILE = NSOutlineViewInSwift/Info.plist; 347 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 348 | PRODUCT_BUNDLE_IDENTIFIER = "au.com.electronicinnovations.$(PRODUCT_NAME:rfc1034identifier)"; 349 | PRODUCT_NAME = "$(TARGET_NAME)"; 350 | }; 351 | name = Release; 352 | }; 353 | E60F191D1A2D25CC0094D994 /* Debug */ = { 354 | isa = XCBuildConfiguration; 355 | buildSettings = { 356 | BUNDLE_LOADER = "$(TEST_HOST)"; 357 | COMBINE_HIDPI_IMAGES = YES; 358 | FRAMEWORK_SEARCH_PATHS = ( 359 | "$(DEVELOPER_FRAMEWORKS_DIR)", 360 | "$(inherited)", 361 | ); 362 | GCC_PREPROCESSOR_DEFINITIONS = ( 363 | "DEBUG=1", 364 | "$(inherited)", 365 | ); 366 | INFOPLIST_FILE = NSOutlineViewInSwiftTests/Info.plist; 367 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 368 | PRODUCT_BUNDLE_IDENTIFIER = "au.com.electronicinnovations.$(PRODUCT_NAME:rfc1034identifier)"; 369 | PRODUCT_NAME = "$(TARGET_NAME)"; 370 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NSOutlineViewInSwift.app/Contents/MacOS/NSOutlineViewInSwift"; 371 | }; 372 | name = Debug; 373 | }; 374 | E60F191E1A2D25CC0094D994 /* Release */ = { 375 | isa = XCBuildConfiguration; 376 | buildSettings = { 377 | BUNDLE_LOADER = "$(TEST_HOST)"; 378 | COMBINE_HIDPI_IMAGES = YES; 379 | FRAMEWORK_SEARCH_PATHS = ( 380 | "$(DEVELOPER_FRAMEWORKS_DIR)", 381 | "$(inherited)", 382 | ); 383 | INFOPLIST_FILE = NSOutlineViewInSwiftTests/Info.plist; 384 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 385 | PRODUCT_BUNDLE_IDENTIFIER = "au.com.electronicinnovations.$(PRODUCT_NAME:rfc1034identifier)"; 386 | PRODUCT_NAME = "$(TARGET_NAME)"; 387 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NSOutlineViewInSwift.app/Contents/MacOS/NSOutlineViewInSwift"; 388 | }; 389 | name = Release; 390 | }; 391 | /* End XCBuildConfiguration section */ 392 | 393 | /* Begin XCConfigurationList section */ 394 | E60F18F81A2D25CC0094D994 /* Build configuration list for PBXProject "NSOutlineViewInSwift" */ = { 395 | isa = XCConfigurationList; 396 | buildConfigurations = ( 397 | E60F19171A2D25CC0094D994 /* Debug */, 398 | E60F19181A2D25CC0094D994 /* Release */, 399 | ); 400 | defaultConfigurationIsVisible = 0; 401 | defaultConfigurationName = Release; 402 | }; 403 | E60F19191A2D25CC0094D994 /* Build configuration list for PBXNativeTarget "NSOutlineViewInSwift" */ = { 404 | isa = XCConfigurationList; 405 | buildConfigurations = ( 406 | E60F191A1A2D25CC0094D994 /* Debug */, 407 | E60F191B1A2D25CC0094D994 /* Release */, 408 | ); 409 | defaultConfigurationIsVisible = 0; 410 | defaultConfigurationName = Release; 411 | }; 412 | E60F191C1A2D25CC0094D994 /* Build configuration list for PBXNativeTarget "NSOutlineViewInSwiftTests" */ = { 413 | isa = XCConfigurationList; 414 | buildConfigurations = ( 415 | E60F191D1A2D25CC0094D994 /* Debug */, 416 | E60F191E1A2D25CC0094D994 /* Release */, 417 | ); 418 | defaultConfigurationIsVisible = 0; 419 | defaultConfigurationName = Release; 420 | }; 421 | /* End XCConfigurationList section */ 422 | }; 423 | rootObject = E60F18F51A2D25CC0094D994 /* Project object */; 424 | } 425 | -------------------------------------------------------------------------------- /NSOutlineViewInSwift/NSOutlineViewInSwift.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NSOutlineViewInSwift/NSOutlineViewInSwift/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // NSOutlineViewInSwift 4 | // 5 | // Created by Daniel Pink on 2/12/2014. 6 | // Copyright (c) 2014 Electronic Innovations. 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 | -------------------------------------------------------------------------------- /NSOutlineViewInSwift/NSOutlineViewInSwift/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 | Default 510 | 511 | 512 | 513 | 514 | 515 | 516 | Left to Right 517 | 518 | 519 | 520 | 521 | 522 | 523 | Right to Left 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | Default 535 | 536 | 537 | 538 | 539 | 540 | 541 | Left to Right 542 | 543 | 544 | 545 | 546 | 547 | 548 | Right to Left 549 | 550 | 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 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | -------------------------------------------------------------------------------- /NSOutlineViewInSwift/NSOutlineViewInSwift/FileSystemItem.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FileSystemItem.swift 3 | // NSOutlineViewInSwift 4 | // 5 | // Created by Daniel Pink on 2/12/2014. 6 | // Copyright (c) 2014 Electronic Innovations. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | public class FileSystemItem: NSObject { 12 | 13 | var relativePath: String 14 | var parent: FileSystemItem? 15 | 16 | lazy var children: [FileSystemItem]? = { 17 | let fileManager = NSFileManager.defaultManager() 18 | let fullPath = self.fullPath() 19 | var isDir = ObjCBool(false) 20 | let valid = fileManager.fileExistsAtPath(fullPath as String, isDirectory: &isDir) 21 | var newChildren: [FileSystemItem] = [] 22 | 23 | if (valid && isDir.boolValue) { 24 | let array: [AnyObject]? 25 | do { 26 | array = try fileManager.contentsOfDirectoryAtPath(fullPath as String) 27 | } catch _ { 28 | array = nil 29 | } 30 | 31 | if let ar = array as? [String] { 32 | for contents in ar { 33 | let newChild = FileSystemItem(path: contents, parent: self) 34 | newChildren.append(newChild) 35 | } 36 | } 37 | return newChildren 38 | } else { 39 | return nil 40 | } 41 | }() 42 | 43 | public override var description: String { 44 | return "FileSystemItem:\(relativePath)" 45 | } 46 | 47 | init(path: NSString, parent: FileSystemItem?) { 48 | self.relativePath = path.lastPathComponent.copy() as! String 49 | self.parent = parent 50 | } 51 | 52 | class var rootItem: FileSystemItem { 53 | get { 54 | return FileSystemItem(path:"/", parent: nil) 55 | } 56 | } 57 | 58 | public func numberOfChildren() -> Int { 59 | guard let children = self.children else { return 0 } 60 | return children.count 61 | } 62 | 63 | public func childAtIndex(n: Int) -> FileSystemItem? { 64 | guard let children = self.children else { return nil } 65 | return children[n] 66 | } 67 | 68 | public func fullPath() -> NSString { 69 | guard let parent = self.parent else { return relativePath } 70 | return parent.fullPath().stringByAppendingPathComponent(relativePath as String) 71 | } 72 | } 73 | 74 | /* 75 | @interface FileSystemItem : NSObject 76 | { 77 | NSString *relativePath; 78 | FileSystemItem *parent; 79 | NSMutableArray *children; 80 | } 81 | 82 | + (FileSystemItem *)rootItem; 83 | - (NSInteger)numberOfChildren;// Returns -1 for leaf nodes 84 | - (FileSystemItem *)childAtIndex:(NSUInteger)n; // Invalid to call on leaf nodes 85 | - (NSString *)fullPath; 86 | - (NSString *)relativePath; 87 | 88 | @end 89 | 90 | 91 | @implementation FileSystemItem 92 | 93 | static FileSystemItem *rootItem = nil; 94 | static NSMutableArray *leafNode = nil; 95 | 96 | + (void)initialize { 97 | if (self == [FileSystemItem class]) { 98 | leafNode = [[NSMutableArray alloc] init]; 99 | } 100 | } 101 | 102 | - (id)initWithPath:(NSString *)path parent:(FileSystemItem *)parentItem { 103 | self = [super init]; 104 | if (self) { 105 | relativePath = [[path lastPathComponent] copy]; 106 | parent = parentItem; 107 | } 108 | return self; 109 | } 110 | 111 | 112 | + (FileSystemItem *)rootItem { 113 | if (rootItem == nil) { 114 | rootItem = [[FileSystemItem alloc] initWithPath:@"/" parent:nil]; 115 | } 116 | return rootItem; 117 | } 118 | 119 | 120 | // Creates, caches, and returns the array of children 121 | // Loads children incrementally 122 | - (NSArray *)children { 123 | 124 | if (children == nil) { 125 | NSFileManager *fileManager = [NSFileManager defaultManager]; 126 | NSString *fullPath = [self fullPath]; 127 | BOOL isDir, valid; 128 | 129 | valid = [fileManager fileExistsAtPath:fullPath isDirectory:&isDir]; 130 | 131 | if (valid && isDir) { 132 | NSArray *array = [fileManager contentsOfDirectoryAtPath:fullPath error:NULL]; 133 | 134 | NSUInteger numChildren, i; 135 | 136 | numChildren = [array count]; 137 | children = [[NSMutableArray alloc] initWithCapacity:numChildren]; 138 | 139 | for (i = 0; i < numChildren; i++) 140 | { 141 | FileSystemItem *newChild = [[FileSystemItem alloc] 142 | initWithPath:[array objectAtIndex:i] parent:self]; 143 | [children addObject:newChild]; 144 | [newChild release]; 145 | } 146 | } 147 | else { 148 | children = leafNode; 149 | } 150 | } 151 | return children; 152 | } 153 | 154 | 155 | - (NSString *)relativePath { 156 | return relativePath; 157 | } 158 | 159 | 160 | - (NSString *)fullPath { 161 | // If no parent, return our own relative path 162 | if (parent == nil) { 163 | return relativePath; 164 | } 165 | 166 | // recurse up the hierarchy, prepending each parent’s path 167 | return [[parent fullPath] stringByAppendingPathComponent:relativePath]; 168 | } 169 | 170 | 171 | - (FileSystemItem *)childAtIndex:(NSUInteger)n { 172 | return [[self children] objectAtIndex:n]; 173 | } 174 | 175 | 176 | - (NSInteger)numberOfChildren { 177 | NSArray *tmp = [self children]; 178 | return (tmp == leafNode) ? (-1) : [tmp count]; 179 | } 180 | 181 | 182 | - (void)dealloc { 183 | if (children != leafNode) { 184 | [children release]; 185 | } 186 | [relativePath release]; 187 | [super dealloc]; 188 | } 189 | 190 | @end 191 | 192 | */ -------------------------------------------------------------------------------- /NSOutlineViewInSwift/NSOutlineViewInSwift/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 | } -------------------------------------------------------------------------------- /NSOutlineViewInSwift/NSOutlineViewInSwift/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 © 2014 Electronic Innovations. All rights reserved. 29 | NSMainStoryboardFile 30 | Main 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /NSOutlineViewInSwift/NSOutlineViewInSwift/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // NSOutlineViewInSwift 4 | // 5 | // Created by Daniel Pink on 2/12/2014. 6 | // Copyright (c) 2014 Electronic Innovations. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | class ViewController: NSViewController { 12 | 13 | @IBOutlet var outlineView: NSOutlineView! 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | // Do any additional setup after loading the view. 19 | outlineView.headerView = nil 20 | } 21 | 22 | } 23 | 24 | 25 | // MARK:- Outline View Data Source 26 | 27 | extension ViewController: NSOutlineViewDataSource { 28 | 29 | func outlineView(outlineView: NSOutlineView, child index: Int, ofItem item: AnyObject?) -> AnyObject { 30 | // return (item == nil) ? [FileSystemItem rootItem] : [(FileSystemItem *)item childAtIndex:index]; 31 | 32 | guard let fileSystemItem = item as? FileSystemItem else { 33 | print("child:ofItem: return the rootItem") 34 | return FileSystemItem.rootItem 35 | } 36 | 37 | print("child: \(index) ofItem: \(fileSystemItem)") 38 | return fileSystemItem.childAtIndex(index)! 39 | } 40 | 41 | func outlineView(outlineView: NSOutlineView, isItemExpandable item: AnyObject) -> Bool { 42 | // return (item == nil) ? YES : ([item numberOfChildren] != -1); 43 | 44 | guard let fileSystemItem = item as? FileSystemItem else { 45 | // This is the root item which is always expandable 46 | return true 47 | } 48 | 49 | return fileSystemItem.numberOfChildren() > 0 50 | } 51 | 52 | func outlineView(outlineView: NSOutlineView, numberOfChildrenOfItem item: AnyObject?) -> Int { 53 | // return (item == nil) ? 1 : [item numberOfChildren]; 54 | 55 | guard let fileSystemItem = item as? FileSystemItem else { 56 | print("numberOfChildrenOfItem: We have been passed the root object so we return 1") 57 | return 1 58 | } 59 | 60 | print("numberOfChildrenOfItem: \(fileSystemItem.numberOfChildren())") 61 | return fileSystemItem.numberOfChildren() 62 | } 63 | 64 | func outlineView(outlineView: NSOutlineView, objectValueForTableColumn: NSTableColumn?, byItem:AnyObject?) -> AnyObject? { 65 | // return (item == nil) ? @"/" : [item relativePath]; 66 | 67 | guard let fileSystemItem = byItem as? FileSystemItem else { 68 | return nil 69 | } 70 | 71 | print("objectValueForTableColumn:byItem: \(fileSystemItem)") 72 | return fileSystemItem.relativePath 73 | } 74 | } 75 | 76 | /* 77 | @implementation DataSource 78 | // Data Source methods 79 | 80 | - (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item { 81 | 82 | return (item == nil) ? 1 : [item numberOfChildren]; 83 | } 84 | 85 | 86 | - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item { 87 | return (item == nil) ? YES : ([item numberOfChildren] != -1); 88 | } 89 | 90 | 91 | - (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item { 92 | 93 | return (item == nil) ? [FileSystemItem rootItem] : [(FileSystemItem *)item childAtIndex:index]; 94 | } 95 | 96 | 97 | - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item { 98 | return (item == nil) ? @"/" : [item relativePath]; 99 | } 100 | 101 | @end 102 | */ -------------------------------------------------------------------------------- /NSOutlineViewInSwift/NSOutlineViewInSwiftTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /NSOutlineViewInSwift/NSOutlineViewInSwiftTests/NSOutlineViewInSwiftTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NSOutlineViewInSwiftTests.swift 3 | // NSOutlineViewInSwiftTests 4 | // 5 | // Created by Daniel Pink on 2/12/2014. 6 | // Copyright (c) 2014 Electronic Innovations. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import XCTest 11 | 12 | class NSOutlineViewInSwiftTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /NSOutlineViewUsingViewMode/NSOutlineViewUsingViewMode.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | E6FFDF791A2D733800125DE8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6FFDF781A2D733800125DE8 /* AppDelegate.swift */; }; 11 | E6FFDF7B1A2D733800125DE8 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6FFDF7A1A2D733800125DE8 /* ViewController.swift */; }; 12 | E6FFDF7D1A2D733800125DE8 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E6FFDF7C1A2D733800125DE8 /* Images.xcassets */; }; 13 | E6FFDF801A2D733800125DE8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E6FFDF7E1A2D733800125DE8 /* Main.storyboard */; }; 14 | E6FFDF8C1A2D733800125DE8 /* NSOutlineViewUsingViewModeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6FFDF8B1A2D733800125DE8 /* NSOutlineViewUsingViewModeTests.swift */; }; 15 | E6FFDF961A2D73CF00125DE8 /* FileSystemItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6FFDF951A2D73CF00125DE8 /* FileSystemItem.swift */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXContainerItemProxy section */ 19 | E6FFDF861A2D733800125DE8 /* PBXContainerItemProxy */ = { 20 | isa = PBXContainerItemProxy; 21 | containerPortal = E6FFDF6B1A2D733800125DE8 /* Project object */; 22 | proxyType = 1; 23 | remoteGlobalIDString = E6FFDF721A2D733800125DE8; 24 | remoteInfo = NSOutlineViewUsingViewMode; 25 | }; 26 | /* End PBXContainerItemProxy section */ 27 | 28 | /* Begin PBXFileReference section */ 29 | E6FFDF731A2D733800125DE8 /* NSOutlineViewUsingViewMode.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NSOutlineViewUsingViewMode.app; sourceTree = BUILT_PRODUCTS_DIR; }; 30 | E6FFDF771A2D733800125DE8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 31 | E6FFDF781A2D733800125DE8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 32 | E6FFDF7A1A2D733800125DE8 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 33 | E6FFDF7C1A2D733800125DE8 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 34 | E6FFDF7F1A2D733800125DE8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 35 | E6FFDF851A2D733800125DE8 /* NSOutlineViewUsingViewModeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NSOutlineViewUsingViewModeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 36 | E6FFDF8A1A2D733800125DE8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 37 | E6FFDF8B1A2D733800125DE8 /* NSOutlineViewUsingViewModeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSOutlineViewUsingViewModeTests.swift; sourceTree = ""; }; 38 | E6FFDF951A2D73CF00125DE8 /* FileSystemItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FileSystemItem.swift; path = ../../NSOutlineViewInSwift/NSOutlineViewInSwift/FileSystemItem.swift; sourceTree = ""; }; 39 | /* End PBXFileReference section */ 40 | 41 | /* Begin PBXFrameworksBuildPhase section */ 42 | E6FFDF701A2D733800125DE8 /* Frameworks */ = { 43 | isa = PBXFrameworksBuildPhase; 44 | buildActionMask = 2147483647; 45 | files = ( 46 | ); 47 | runOnlyForDeploymentPostprocessing = 0; 48 | }; 49 | E6FFDF821A2D733800125DE8 /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | /* End PBXFrameworksBuildPhase section */ 57 | 58 | /* Begin PBXGroup section */ 59 | E6FFDF6A1A2D733800125DE8 = { 60 | isa = PBXGroup; 61 | children = ( 62 | E6FFDF751A2D733800125DE8 /* NSOutlineViewUsingViewMode */, 63 | E6FFDF881A2D733800125DE8 /* NSOutlineViewUsingViewModeTests */, 64 | E6FFDF741A2D733800125DE8 /* Products */, 65 | ); 66 | sourceTree = ""; 67 | }; 68 | E6FFDF741A2D733800125DE8 /* Products */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | E6FFDF731A2D733800125DE8 /* NSOutlineViewUsingViewMode.app */, 72 | E6FFDF851A2D733800125DE8 /* NSOutlineViewUsingViewModeTests.xctest */, 73 | ); 74 | name = Products; 75 | sourceTree = ""; 76 | }; 77 | E6FFDF751A2D733800125DE8 /* NSOutlineViewUsingViewMode */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | E6FFDF781A2D733800125DE8 /* AppDelegate.swift */, 81 | E6FFDF7A1A2D733800125DE8 /* ViewController.swift */, 82 | E6FFDF951A2D73CF00125DE8 /* FileSystemItem.swift */, 83 | E6FFDF7C1A2D733800125DE8 /* Images.xcassets */, 84 | E6FFDF7E1A2D733800125DE8 /* Main.storyboard */, 85 | E6FFDF761A2D733800125DE8 /* Supporting Files */, 86 | ); 87 | path = NSOutlineViewUsingViewMode; 88 | sourceTree = ""; 89 | }; 90 | E6FFDF761A2D733800125DE8 /* Supporting Files */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | E6FFDF771A2D733800125DE8 /* Info.plist */, 94 | ); 95 | name = "Supporting Files"; 96 | sourceTree = ""; 97 | }; 98 | E6FFDF881A2D733800125DE8 /* NSOutlineViewUsingViewModeTests */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | E6FFDF8B1A2D733800125DE8 /* NSOutlineViewUsingViewModeTests.swift */, 102 | E6FFDF891A2D733800125DE8 /* Supporting Files */, 103 | ); 104 | path = NSOutlineViewUsingViewModeTests; 105 | sourceTree = ""; 106 | }; 107 | E6FFDF891A2D733800125DE8 /* Supporting Files */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | E6FFDF8A1A2D733800125DE8 /* Info.plist */, 111 | ); 112 | name = "Supporting Files"; 113 | sourceTree = ""; 114 | }; 115 | /* End PBXGroup section */ 116 | 117 | /* Begin PBXNativeTarget section */ 118 | E6FFDF721A2D733800125DE8 /* NSOutlineViewUsingViewMode */ = { 119 | isa = PBXNativeTarget; 120 | buildConfigurationList = E6FFDF8F1A2D733800125DE8 /* Build configuration list for PBXNativeTarget "NSOutlineViewUsingViewMode" */; 121 | buildPhases = ( 122 | E6FFDF6F1A2D733800125DE8 /* Sources */, 123 | E6FFDF701A2D733800125DE8 /* Frameworks */, 124 | E6FFDF711A2D733800125DE8 /* Resources */, 125 | ); 126 | buildRules = ( 127 | ); 128 | dependencies = ( 129 | ); 130 | name = NSOutlineViewUsingViewMode; 131 | productName = NSOutlineViewUsingViewMode; 132 | productReference = E6FFDF731A2D733800125DE8 /* NSOutlineViewUsingViewMode.app */; 133 | productType = "com.apple.product-type.application"; 134 | }; 135 | E6FFDF841A2D733800125DE8 /* NSOutlineViewUsingViewModeTests */ = { 136 | isa = PBXNativeTarget; 137 | buildConfigurationList = E6FFDF921A2D733800125DE8 /* Build configuration list for PBXNativeTarget "NSOutlineViewUsingViewModeTests" */; 138 | buildPhases = ( 139 | E6FFDF811A2D733800125DE8 /* Sources */, 140 | E6FFDF821A2D733800125DE8 /* Frameworks */, 141 | E6FFDF831A2D733800125DE8 /* Resources */, 142 | ); 143 | buildRules = ( 144 | ); 145 | dependencies = ( 146 | E6FFDF871A2D733800125DE8 /* PBXTargetDependency */, 147 | ); 148 | name = NSOutlineViewUsingViewModeTests; 149 | productName = NSOutlineViewUsingViewModeTests; 150 | productReference = E6FFDF851A2D733800125DE8 /* NSOutlineViewUsingViewModeTests.xctest */; 151 | productType = "com.apple.product-type.bundle.unit-test"; 152 | }; 153 | /* End PBXNativeTarget section */ 154 | 155 | /* Begin PBXProject section */ 156 | E6FFDF6B1A2D733800125DE8 /* Project object */ = { 157 | isa = PBXProject; 158 | attributes = { 159 | LastSwiftUpdateCheck = 0700; 160 | LastUpgradeCheck = 0610; 161 | ORGANIZATIONNAME = "Electronic Innovations"; 162 | TargetAttributes = { 163 | E6FFDF721A2D733800125DE8 = { 164 | CreatedOnToolsVersion = 6.1; 165 | }; 166 | E6FFDF841A2D733800125DE8 = { 167 | CreatedOnToolsVersion = 6.1; 168 | TestTargetID = E6FFDF721A2D733800125DE8; 169 | }; 170 | }; 171 | }; 172 | buildConfigurationList = E6FFDF6E1A2D733800125DE8 /* Build configuration list for PBXProject "NSOutlineViewUsingViewMode" */; 173 | compatibilityVersion = "Xcode 3.2"; 174 | developmentRegion = English; 175 | hasScannedForEncodings = 0; 176 | knownRegions = ( 177 | en, 178 | Base, 179 | ); 180 | mainGroup = E6FFDF6A1A2D733800125DE8; 181 | productRefGroup = E6FFDF741A2D733800125DE8 /* Products */; 182 | projectDirPath = ""; 183 | projectRoot = ""; 184 | targets = ( 185 | E6FFDF721A2D733800125DE8 /* NSOutlineViewUsingViewMode */, 186 | E6FFDF841A2D733800125DE8 /* NSOutlineViewUsingViewModeTests */, 187 | ); 188 | }; 189 | /* End PBXProject section */ 190 | 191 | /* Begin PBXResourcesBuildPhase section */ 192 | E6FFDF711A2D733800125DE8 /* Resources */ = { 193 | isa = PBXResourcesBuildPhase; 194 | buildActionMask = 2147483647; 195 | files = ( 196 | E6FFDF7D1A2D733800125DE8 /* Images.xcassets in Resources */, 197 | E6FFDF801A2D733800125DE8 /* Main.storyboard in Resources */, 198 | ); 199 | runOnlyForDeploymentPostprocessing = 0; 200 | }; 201 | E6FFDF831A2D733800125DE8 /* Resources */ = { 202 | isa = PBXResourcesBuildPhase; 203 | buildActionMask = 2147483647; 204 | files = ( 205 | ); 206 | runOnlyForDeploymentPostprocessing = 0; 207 | }; 208 | /* End PBXResourcesBuildPhase section */ 209 | 210 | /* Begin PBXSourcesBuildPhase section */ 211 | E6FFDF6F1A2D733800125DE8 /* Sources */ = { 212 | isa = PBXSourcesBuildPhase; 213 | buildActionMask = 2147483647; 214 | files = ( 215 | E6FFDF7B1A2D733800125DE8 /* ViewController.swift in Sources */, 216 | E6FFDF961A2D73CF00125DE8 /* FileSystemItem.swift in Sources */, 217 | E6FFDF791A2D733800125DE8 /* AppDelegate.swift in Sources */, 218 | ); 219 | runOnlyForDeploymentPostprocessing = 0; 220 | }; 221 | E6FFDF811A2D733800125DE8 /* Sources */ = { 222 | isa = PBXSourcesBuildPhase; 223 | buildActionMask = 2147483647; 224 | files = ( 225 | E6FFDF8C1A2D733800125DE8 /* NSOutlineViewUsingViewModeTests.swift in Sources */, 226 | ); 227 | runOnlyForDeploymentPostprocessing = 0; 228 | }; 229 | /* End PBXSourcesBuildPhase section */ 230 | 231 | /* Begin PBXTargetDependency section */ 232 | E6FFDF871A2D733800125DE8 /* PBXTargetDependency */ = { 233 | isa = PBXTargetDependency; 234 | target = E6FFDF721A2D733800125DE8 /* NSOutlineViewUsingViewMode */; 235 | targetProxy = E6FFDF861A2D733800125DE8 /* PBXContainerItemProxy */; 236 | }; 237 | /* End PBXTargetDependency section */ 238 | 239 | /* Begin PBXVariantGroup section */ 240 | E6FFDF7E1A2D733800125DE8 /* Main.storyboard */ = { 241 | isa = PBXVariantGroup; 242 | children = ( 243 | E6FFDF7F1A2D733800125DE8 /* Base */, 244 | ); 245 | name = Main.storyboard; 246 | sourceTree = ""; 247 | }; 248 | /* End PBXVariantGroup section */ 249 | 250 | /* Begin XCBuildConfiguration section */ 251 | E6FFDF8D1A2D733800125DE8 /* Debug */ = { 252 | isa = XCBuildConfiguration; 253 | buildSettings = { 254 | ALWAYS_SEARCH_USER_PATHS = NO; 255 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 256 | CLANG_CXX_LIBRARY = "libc++"; 257 | CLANG_ENABLE_MODULES = YES; 258 | CLANG_ENABLE_OBJC_ARC = YES; 259 | CLANG_WARN_BOOL_CONVERSION = YES; 260 | CLANG_WARN_CONSTANT_CONVERSION = YES; 261 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 262 | CLANG_WARN_EMPTY_BODY = YES; 263 | CLANG_WARN_ENUM_CONVERSION = YES; 264 | CLANG_WARN_INT_CONVERSION = YES; 265 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 266 | CLANG_WARN_UNREACHABLE_CODE = YES; 267 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 268 | CODE_SIGN_IDENTITY = "-"; 269 | COPY_PHASE_STRIP = NO; 270 | ENABLE_STRICT_OBJC_MSGSEND = YES; 271 | GCC_C_LANGUAGE_STANDARD = gnu99; 272 | GCC_DYNAMIC_NO_PIC = NO; 273 | GCC_OPTIMIZATION_LEVEL = 0; 274 | GCC_PREPROCESSOR_DEFINITIONS = ( 275 | "DEBUG=1", 276 | "$(inherited)", 277 | ); 278 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 279 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 280 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 281 | GCC_WARN_UNDECLARED_SELECTOR = YES; 282 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 283 | GCC_WARN_UNUSED_FUNCTION = YES; 284 | GCC_WARN_UNUSED_VARIABLE = YES; 285 | MACOSX_DEPLOYMENT_TARGET = 10.10; 286 | MTL_ENABLE_DEBUG_INFO = YES; 287 | ONLY_ACTIVE_ARCH = YES; 288 | SDKROOT = macosx; 289 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 290 | }; 291 | name = Debug; 292 | }; 293 | E6FFDF8E1A2D733800125DE8 /* Release */ = { 294 | isa = XCBuildConfiguration; 295 | buildSettings = { 296 | ALWAYS_SEARCH_USER_PATHS = NO; 297 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 298 | CLANG_CXX_LIBRARY = "libc++"; 299 | CLANG_ENABLE_MODULES = YES; 300 | CLANG_ENABLE_OBJC_ARC = YES; 301 | CLANG_WARN_BOOL_CONVERSION = YES; 302 | CLANG_WARN_CONSTANT_CONVERSION = YES; 303 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 304 | CLANG_WARN_EMPTY_BODY = YES; 305 | CLANG_WARN_ENUM_CONVERSION = YES; 306 | CLANG_WARN_INT_CONVERSION = YES; 307 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 308 | CLANG_WARN_UNREACHABLE_CODE = YES; 309 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 310 | CODE_SIGN_IDENTITY = "-"; 311 | COPY_PHASE_STRIP = YES; 312 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 313 | ENABLE_NS_ASSERTIONS = NO; 314 | ENABLE_STRICT_OBJC_MSGSEND = YES; 315 | GCC_C_LANGUAGE_STANDARD = gnu99; 316 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 317 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 318 | GCC_WARN_UNDECLARED_SELECTOR = YES; 319 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 320 | GCC_WARN_UNUSED_FUNCTION = YES; 321 | GCC_WARN_UNUSED_VARIABLE = YES; 322 | MACOSX_DEPLOYMENT_TARGET = 10.10; 323 | MTL_ENABLE_DEBUG_INFO = NO; 324 | SDKROOT = macosx; 325 | }; 326 | name = Release; 327 | }; 328 | E6FFDF901A2D733800125DE8 /* Debug */ = { 329 | isa = XCBuildConfiguration; 330 | buildSettings = { 331 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 332 | COMBINE_HIDPI_IMAGES = YES; 333 | INFOPLIST_FILE = NSOutlineViewUsingViewMode/Info.plist; 334 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 335 | PRODUCT_NAME = "$(TARGET_NAME)"; 336 | }; 337 | name = Debug; 338 | }; 339 | E6FFDF911A2D733800125DE8 /* Release */ = { 340 | isa = XCBuildConfiguration; 341 | buildSettings = { 342 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 343 | COMBINE_HIDPI_IMAGES = YES; 344 | INFOPLIST_FILE = NSOutlineViewUsingViewMode/Info.plist; 345 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 346 | PRODUCT_NAME = "$(TARGET_NAME)"; 347 | }; 348 | name = Release; 349 | }; 350 | E6FFDF931A2D733800125DE8 /* Debug */ = { 351 | isa = XCBuildConfiguration; 352 | buildSettings = { 353 | BUNDLE_LOADER = "$(TEST_HOST)"; 354 | COMBINE_HIDPI_IMAGES = YES; 355 | FRAMEWORK_SEARCH_PATHS = ( 356 | "$(DEVELOPER_FRAMEWORKS_DIR)", 357 | "$(inherited)", 358 | ); 359 | GCC_PREPROCESSOR_DEFINITIONS = ( 360 | "DEBUG=1", 361 | "$(inherited)", 362 | ); 363 | INFOPLIST_FILE = NSOutlineViewUsingViewModeTests/Info.plist; 364 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 365 | PRODUCT_NAME = "$(TARGET_NAME)"; 366 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NSOutlineViewUsingViewMode.app/Contents/MacOS/NSOutlineViewUsingViewMode"; 367 | }; 368 | name = Debug; 369 | }; 370 | E6FFDF941A2D733800125DE8 /* Release */ = { 371 | isa = XCBuildConfiguration; 372 | buildSettings = { 373 | BUNDLE_LOADER = "$(TEST_HOST)"; 374 | COMBINE_HIDPI_IMAGES = YES; 375 | FRAMEWORK_SEARCH_PATHS = ( 376 | "$(DEVELOPER_FRAMEWORKS_DIR)", 377 | "$(inherited)", 378 | ); 379 | INFOPLIST_FILE = NSOutlineViewUsingViewModeTests/Info.plist; 380 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 381 | PRODUCT_NAME = "$(TARGET_NAME)"; 382 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NSOutlineViewUsingViewMode.app/Contents/MacOS/NSOutlineViewUsingViewMode"; 383 | }; 384 | name = Release; 385 | }; 386 | /* End XCBuildConfiguration section */ 387 | 388 | /* Begin XCConfigurationList section */ 389 | E6FFDF6E1A2D733800125DE8 /* Build configuration list for PBXProject "NSOutlineViewUsingViewMode" */ = { 390 | isa = XCConfigurationList; 391 | buildConfigurations = ( 392 | E6FFDF8D1A2D733800125DE8 /* Debug */, 393 | E6FFDF8E1A2D733800125DE8 /* Release */, 394 | ); 395 | defaultConfigurationIsVisible = 0; 396 | defaultConfigurationName = Release; 397 | }; 398 | E6FFDF8F1A2D733800125DE8 /* Build configuration list for PBXNativeTarget "NSOutlineViewUsingViewMode" */ = { 399 | isa = XCConfigurationList; 400 | buildConfigurations = ( 401 | E6FFDF901A2D733800125DE8 /* Debug */, 402 | E6FFDF911A2D733800125DE8 /* Release */, 403 | ); 404 | defaultConfigurationIsVisible = 0; 405 | defaultConfigurationName = Release; 406 | }; 407 | E6FFDF921A2D733800125DE8 /* Build configuration list for PBXNativeTarget "NSOutlineViewUsingViewModeTests" */ = { 408 | isa = XCConfigurationList; 409 | buildConfigurations = ( 410 | E6FFDF931A2D733800125DE8 /* Debug */, 411 | E6FFDF941A2D733800125DE8 /* Release */, 412 | ); 413 | defaultConfigurationIsVisible = 0; 414 | defaultConfigurationName = Release; 415 | }; 416 | /* End XCConfigurationList section */ 417 | }; 418 | rootObject = E6FFDF6B1A2D733800125DE8 /* Project object */; 419 | } 420 | -------------------------------------------------------------------------------- /NSOutlineViewUsingViewMode/NSOutlineViewUsingViewMode.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NSOutlineViewUsingViewMode/NSOutlineViewUsingViewMode/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // NSOutlineViewUsingViewMode 4 | // 5 | // Created by Daniel Pink on 2/12/2014. 6 | // Copyright (c) 2014 Electronic Innovations. 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 | -------------------------------------------------------------------------------- /NSOutlineViewUsingViewMode/NSOutlineViewUsingViewMode/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 | } -------------------------------------------------------------------------------- /NSOutlineViewUsingViewMode/NSOutlineViewUsingViewMode/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | au.com.electronicinnovations.$(PRODUCT_NAME:rfc1034identifier) 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 © 2014 Electronic Innovations. All rights reserved. 29 | NSMainStoryboardFile 30 | Main 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /NSOutlineViewUsingViewMode/NSOutlineViewUsingViewMode/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // NSOutlineViewInSwift 4 | // 5 | // Created by Daniel Pink on 2/12/2014. 6 | // Copyright (c) 2014 Electronic Innovations. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | class ViewController: NSViewController, NSOutlineViewDelegate, NSOutlineViewDataSource { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | // Do any additional setup after loading the view. 17 | } 18 | 19 | override var representedObject: AnyObject? { 20 | didSet { 21 | // Update the view, if already loaded. 22 | } 23 | } 24 | 25 | 26 | func outlineView(outlineView: NSOutlineView, child index: Int, ofItem item: AnyObject?) -> AnyObject { 27 | // return (item == nil) ? [FileSystemItem rootItem] : [(FileSystemItem *)item childAtIndex:index]; 28 | if let it = item as? FileSystemItem { 29 | print("child: \(index) ofItem: \(it)") 30 | return it.childAtIndex(index)! 31 | } else { 32 | print("child:ofItem: return the rootItem") 33 | return FileSystemItem.rootItem 34 | } 35 | } 36 | 37 | func outlineView(outlineView: NSOutlineView, isItemExpandable item: AnyObject) -> Bool { 38 | // return (item == nil) ? YES : ([item numberOfChildren] != -1); 39 | if let it = item as? FileSystemItem { 40 | if it.numberOfChildren() > 0 { 41 | print("isItemExpandable: \(it): Yes") 42 | return true 43 | } else { 44 | print("isItemExpandable: \(it): No") 45 | return false 46 | } 47 | } else { 48 | print("isItemExpandable: rootItem: Yes") 49 | return true 50 | } 51 | } 52 | 53 | func outlineView(outlineView: NSOutlineView, numberOfChildrenOfItem item: AnyObject?) -> Int { 54 | // return (item == nil) ? 1 : [item numberOfChildren]; 55 | if let it = item as? FileSystemItem { 56 | print("numberOfChildrenOfItem: \(it.numberOfChildren())") 57 | return it.numberOfChildren() 58 | } 59 | print("numberOfChildrenOfItem: We have been passed the root object so we return 1") 60 | return 1 61 | } 62 | 63 | 64 | // NSOutlineViewDelegate 65 | func outlineView(outlineView: NSOutlineView, viewForTableColumn: NSTableColumn?, item: AnyObject) -> NSView? { 66 | 67 | let view = outlineView.makeViewWithIdentifier("DataCell", owner: self) as! NSTableCellView 68 | if let it = item as? FileSystemItem { 69 | if let textField = view.textField { 70 | textField.stringValue = it.relativePath 71 | } 72 | return view 73 | } else { 74 | if let textField = view.textField { 75 | textField.stringValue = "/" 76 | } 77 | 78 | } 79 | return view 80 | } 81 | 82 | } 83 | 84 | /* 85 | @implementation DataSource 86 | // Data Source methods 87 | 88 | - (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item { 89 | 90 | return (item == nil) ? 1 : [item numberOfChildren]; 91 | } 92 | 93 | 94 | - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item { 95 | return (item == nil) ? YES : ([item numberOfChildren] != -1); 96 | } 97 | 98 | 99 | - (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item { 100 | 101 | return (item == nil) ? [FileSystemItem rootItem] : [(FileSystemItem *)item childAtIndex:index]; 102 | } 103 | 104 | 105 | - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item { 106 | return (item == nil) ? @"/" : [item relativePath]; 107 | } 108 | 109 | @end 110 | */ -------------------------------------------------------------------------------- /NSOutlineViewUsingViewMode/NSOutlineViewUsingViewModeTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | au.com.electronicinnovations.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /NSOutlineViewUsingViewMode/NSOutlineViewUsingViewModeTests/NSOutlineViewUsingViewModeTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NSOutlineViewUsingViewModeTests.swift 3 | // NSOutlineViewUsingViewModeTests 4 | // 5 | // Created by Daniel Pink on 2/12/2014. 6 | // Copyright (c) 2014 Electronic Innovations. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import XCTest 11 | 12 | class NSOutlineViewUsingViewModeTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /NSSourceListInSwift/Artwork/Artboard 1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/NSOutlineViewInSwift/fc8d60f0139b7b21ba4ee3c42721946982136b23/NSSourceListInSwift/Artwork/Artboard 1.pdf -------------------------------------------------------------------------------- /NSSourceListInSwift/Artwork/Artboard 2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/NSOutlineViewInSwift/fc8d60f0139b7b21ba4ee3c42721946982136b23/NSSourceListInSwift/Artwork/Artboard 2.pdf -------------------------------------------------------------------------------- /NSSourceListInSwift/Artwork/Artboard 3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/NSOutlineViewInSwift/fc8d60f0139b7b21ba4ee3c42721946982136b23/NSSourceListInSwift/Artwork/Artboard 3.pdf -------------------------------------------------------------------------------- /NSSourceListInSwift/Artwork/Artboard 4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/NSOutlineViewInSwift/fc8d60f0139b7b21ba4ee3c42721946982136b23/NSSourceListInSwift/Artwork/Artboard 4.pdf -------------------------------------------------------------------------------- /NSSourceListInSwift/Artwork/Artboard 5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/NSOutlineViewInSwift/fc8d60f0139b7b21ba4ee3c42721946982136b23/NSSourceListInSwift/Artwork/Artboard 5.pdf -------------------------------------------------------------------------------- /NSSourceListInSwift/Icons.sketch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/NSOutlineViewInSwift/fc8d60f0139b7b21ba4ee3c42721946982136b23/NSSourceListInSwift/Icons.sketch -------------------------------------------------------------------------------- /NSSourceListInSwift/NSSourceListInSwift.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | E6FFDFA61A2D831C00125DE8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6FFDFA51A2D831C00125DE8 /* AppDelegate.swift */; }; 11 | E6FFDFA81A2D831C00125DE8 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6FFDFA71A2D831C00125DE8 /* ViewController.swift */; }; 12 | E6FFDFAA1A2D831C00125DE8 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E6FFDFA91A2D831C00125DE8 /* Images.xcassets */; }; 13 | E6FFDFAD1A2D831C00125DE8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E6FFDFAB1A2D831C00125DE8 /* Main.storyboard */; }; 14 | E6FFDFB91A2D831C00125DE8 /* NSSourceListInSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6FFDFB81A2D831C00125DE8 /* NSSourceListInSwiftTests.swift */; }; 15 | E6FFDFC31A2D883200125DE8 /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6FFDFC21A2D883200125DE8 /* Model.swift */; }; 16 | E6FFDFC51A2DC56000125DE8 /* Attributions.rtf in Resources */ = {isa = PBXBuildFile; fileRef = E6FFDFC41A2DC56000125DE8 /* Attributions.rtf */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | E6FFDFB31A2D831C00125DE8 /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = E6FFDF981A2D831B00125DE8 /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = E6FFDF9F1A2D831C00125DE8; 25 | remoteInfo = NSSourceListInSwift; 26 | }; 27 | /* End PBXContainerItemProxy section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | E6FFDFA01A2D831C00125DE8 /* NSSourceListInSwift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NSSourceListInSwift.app; sourceTree = BUILT_PRODUCTS_DIR; }; 31 | E6FFDFA41A2D831C00125DE8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | E6FFDFA51A2D831C00125DE8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 33 | E6FFDFA71A2D831C00125DE8 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 34 | E6FFDFA91A2D831C00125DE8 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 35 | E6FFDFAC1A2D831C00125DE8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 36 | E6FFDFB21A2D831C00125DE8 /* NSSourceListInSwiftTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NSSourceListInSwiftTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 37 | E6FFDFB71A2D831C00125DE8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 38 | E6FFDFB81A2D831C00125DE8 /* NSSourceListInSwiftTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSSourceListInSwiftTests.swift; sourceTree = ""; }; 39 | E6FFDFC21A2D883200125DE8 /* Model.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Model.swift; sourceTree = ""; }; 40 | E6FFDFC41A2DC56000125DE8 /* Attributions.rtf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.rtf; path = Attributions.rtf; sourceTree = ""; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | E6FFDF9D1A2D831C00125DE8 /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | ); 49 | runOnlyForDeploymentPostprocessing = 0; 50 | }; 51 | E6FFDFAF1A2D831C00125DE8 /* Frameworks */ = { 52 | isa = PBXFrameworksBuildPhase; 53 | buildActionMask = 2147483647; 54 | files = ( 55 | ); 56 | runOnlyForDeploymentPostprocessing = 0; 57 | }; 58 | /* End PBXFrameworksBuildPhase section */ 59 | 60 | /* Begin PBXGroup section */ 61 | E6FFDF971A2D831B00125DE8 = { 62 | isa = PBXGroup; 63 | children = ( 64 | E6FFDFA21A2D831C00125DE8 /* NSSourceListInSwift */, 65 | E6FFDFB51A2D831C00125DE8 /* NSSourceListInSwiftTests */, 66 | E6FFDFA11A2D831C00125DE8 /* Products */, 67 | ); 68 | sourceTree = ""; 69 | }; 70 | E6FFDFA11A2D831C00125DE8 /* Products */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | E6FFDFA01A2D831C00125DE8 /* NSSourceListInSwift.app */, 74 | E6FFDFB21A2D831C00125DE8 /* NSSourceListInSwiftTests.xctest */, 75 | ); 76 | name = Products; 77 | sourceTree = ""; 78 | }; 79 | E6FFDFA21A2D831C00125DE8 /* NSSourceListInSwift */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | E6FFDFA51A2D831C00125DE8 /* AppDelegate.swift */, 83 | E6FFDFA71A2D831C00125DE8 /* ViewController.swift */, 84 | E6FFDFC21A2D883200125DE8 /* Model.swift */, 85 | E6FFDFA91A2D831C00125DE8 /* Images.xcassets */, 86 | E6FFDFAB1A2D831C00125DE8 /* Main.storyboard */, 87 | E6FFDFA31A2D831C00125DE8 /* Supporting Files */, 88 | E6FFDFC41A2DC56000125DE8 /* Attributions.rtf */, 89 | ); 90 | path = NSSourceListInSwift; 91 | sourceTree = ""; 92 | }; 93 | E6FFDFA31A2D831C00125DE8 /* Supporting Files */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | E6FFDFA41A2D831C00125DE8 /* Info.plist */, 97 | ); 98 | name = "Supporting Files"; 99 | sourceTree = ""; 100 | }; 101 | E6FFDFB51A2D831C00125DE8 /* NSSourceListInSwiftTests */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | E6FFDFB81A2D831C00125DE8 /* NSSourceListInSwiftTests.swift */, 105 | E6FFDFB61A2D831C00125DE8 /* Supporting Files */, 106 | ); 107 | path = NSSourceListInSwiftTests; 108 | sourceTree = ""; 109 | }; 110 | E6FFDFB61A2D831C00125DE8 /* Supporting Files */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | E6FFDFB71A2D831C00125DE8 /* Info.plist */, 114 | ); 115 | name = "Supporting Files"; 116 | sourceTree = ""; 117 | }; 118 | /* End PBXGroup section */ 119 | 120 | /* Begin PBXNativeTarget section */ 121 | E6FFDF9F1A2D831C00125DE8 /* NSSourceListInSwift */ = { 122 | isa = PBXNativeTarget; 123 | buildConfigurationList = E6FFDFBC1A2D831C00125DE8 /* Build configuration list for PBXNativeTarget "NSSourceListInSwift" */; 124 | buildPhases = ( 125 | E6FFDF9C1A2D831C00125DE8 /* Sources */, 126 | E6FFDF9D1A2D831C00125DE8 /* Frameworks */, 127 | E6FFDF9E1A2D831C00125DE8 /* Resources */, 128 | ); 129 | buildRules = ( 130 | ); 131 | dependencies = ( 132 | ); 133 | name = NSSourceListInSwift; 134 | productName = NSSourceListInSwift; 135 | productReference = E6FFDFA01A2D831C00125DE8 /* NSSourceListInSwift.app */; 136 | productType = "com.apple.product-type.application"; 137 | }; 138 | E6FFDFB11A2D831C00125DE8 /* NSSourceListInSwiftTests */ = { 139 | isa = PBXNativeTarget; 140 | buildConfigurationList = E6FFDFBF1A2D831C00125DE8 /* Build configuration list for PBXNativeTarget "NSSourceListInSwiftTests" */; 141 | buildPhases = ( 142 | E6FFDFAE1A2D831C00125DE8 /* Sources */, 143 | E6FFDFAF1A2D831C00125DE8 /* Frameworks */, 144 | E6FFDFB01A2D831C00125DE8 /* Resources */, 145 | ); 146 | buildRules = ( 147 | ); 148 | dependencies = ( 149 | E6FFDFB41A2D831C00125DE8 /* PBXTargetDependency */, 150 | ); 151 | name = NSSourceListInSwiftTests; 152 | productName = NSSourceListInSwiftTests; 153 | productReference = E6FFDFB21A2D831C00125DE8 /* NSSourceListInSwiftTests.xctest */; 154 | productType = "com.apple.product-type.bundle.unit-test"; 155 | }; 156 | /* End PBXNativeTarget section */ 157 | 158 | /* Begin PBXProject section */ 159 | E6FFDF981A2D831B00125DE8 /* Project object */ = { 160 | isa = PBXProject; 161 | attributes = { 162 | LastSwiftUpdateCheck = 0700; 163 | LastUpgradeCheck = 0700; 164 | ORGANIZATIONNAME = "Electronic Innovations"; 165 | TargetAttributes = { 166 | E6FFDF9F1A2D831C00125DE8 = { 167 | CreatedOnToolsVersion = 6.1; 168 | }; 169 | E6FFDFB11A2D831C00125DE8 = { 170 | CreatedOnToolsVersion = 6.1; 171 | TestTargetID = E6FFDF9F1A2D831C00125DE8; 172 | }; 173 | }; 174 | }; 175 | buildConfigurationList = E6FFDF9B1A2D831B00125DE8 /* Build configuration list for PBXProject "NSSourceListInSwift" */; 176 | compatibilityVersion = "Xcode 3.2"; 177 | developmentRegion = English; 178 | hasScannedForEncodings = 0; 179 | knownRegions = ( 180 | en, 181 | Base, 182 | ); 183 | mainGroup = E6FFDF971A2D831B00125DE8; 184 | productRefGroup = E6FFDFA11A2D831C00125DE8 /* Products */; 185 | projectDirPath = ""; 186 | projectRoot = ""; 187 | targets = ( 188 | E6FFDF9F1A2D831C00125DE8 /* NSSourceListInSwift */, 189 | E6FFDFB11A2D831C00125DE8 /* NSSourceListInSwiftTests */, 190 | ); 191 | }; 192 | /* End PBXProject section */ 193 | 194 | /* Begin PBXResourcesBuildPhase section */ 195 | E6FFDF9E1A2D831C00125DE8 /* Resources */ = { 196 | isa = PBXResourcesBuildPhase; 197 | buildActionMask = 2147483647; 198 | files = ( 199 | E6FFDFC51A2DC56000125DE8 /* Attributions.rtf in Resources */, 200 | E6FFDFAA1A2D831C00125DE8 /* Images.xcassets in Resources */, 201 | E6FFDFAD1A2D831C00125DE8 /* Main.storyboard in Resources */, 202 | ); 203 | runOnlyForDeploymentPostprocessing = 0; 204 | }; 205 | E6FFDFB01A2D831C00125DE8 /* Resources */ = { 206 | isa = PBXResourcesBuildPhase; 207 | buildActionMask = 2147483647; 208 | files = ( 209 | ); 210 | runOnlyForDeploymentPostprocessing = 0; 211 | }; 212 | /* End PBXResourcesBuildPhase section */ 213 | 214 | /* Begin PBXSourcesBuildPhase section */ 215 | E6FFDF9C1A2D831C00125DE8 /* Sources */ = { 216 | isa = PBXSourcesBuildPhase; 217 | buildActionMask = 2147483647; 218 | files = ( 219 | E6FFDFC31A2D883200125DE8 /* Model.swift in Sources */, 220 | E6FFDFA81A2D831C00125DE8 /* ViewController.swift in Sources */, 221 | E6FFDFA61A2D831C00125DE8 /* AppDelegate.swift in Sources */, 222 | ); 223 | runOnlyForDeploymentPostprocessing = 0; 224 | }; 225 | E6FFDFAE1A2D831C00125DE8 /* Sources */ = { 226 | isa = PBXSourcesBuildPhase; 227 | buildActionMask = 2147483647; 228 | files = ( 229 | E6FFDFB91A2D831C00125DE8 /* NSSourceListInSwiftTests.swift in Sources */, 230 | ); 231 | runOnlyForDeploymentPostprocessing = 0; 232 | }; 233 | /* End PBXSourcesBuildPhase section */ 234 | 235 | /* Begin PBXTargetDependency section */ 236 | E6FFDFB41A2D831C00125DE8 /* PBXTargetDependency */ = { 237 | isa = PBXTargetDependency; 238 | target = E6FFDF9F1A2D831C00125DE8 /* NSSourceListInSwift */; 239 | targetProxy = E6FFDFB31A2D831C00125DE8 /* PBXContainerItemProxy */; 240 | }; 241 | /* End PBXTargetDependency section */ 242 | 243 | /* Begin PBXVariantGroup section */ 244 | E6FFDFAB1A2D831C00125DE8 /* Main.storyboard */ = { 245 | isa = PBXVariantGroup; 246 | children = ( 247 | E6FFDFAC1A2D831C00125DE8 /* Base */, 248 | ); 249 | name = Main.storyboard; 250 | sourceTree = ""; 251 | }; 252 | /* End PBXVariantGroup section */ 253 | 254 | /* Begin XCBuildConfiguration section */ 255 | E6FFDFBA1A2D831C00125DE8 /* Debug */ = { 256 | isa = XCBuildConfiguration; 257 | buildSettings = { 258 | ALWAYS_SEARCH_USER_PATHS = NO; 259 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 260 | CLANG_CXX_LIBRARY = "libc++"; 261 | CLANG_ENABLE_MODULES = YES; 262 | CLANG_ENABLE_OBJC_ARC = YES; 263 | CLANG_WARN_BOOL_CONVERSION = YES; 264 | CLANG_WARN_CONSTANT_CONVERSION = YES; 265 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 266 | CLANG_WARN_EMPTY_BODY = YES; 267 | CLANG_WARN_ENUM_CONVERSION = YES; 268 | CLANG_WARN_INT_CONVERSION = YES; 269 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 270 | CLANG_WARN_UNREACHABLE_CODE = YES; 271 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 272 | CODE_SIGN_IDENTITY = "-"; 273 | COPY_PHASE_STRIP = NO; 274 | ENABLE_STRICT_OBJC_MSGSEND = YES; 275 | ENABLE_TESTABILITY = YES; 276 | GCC_C_LANGUAGE_STANDARD = gnu99; 277 | GCC_DYNAMIC_NO_PIC = NO; 278 | GCC_OPTIMIZATION_LEVEL = 0; 279 | GCC_PREPROCESSOR_DEFINITIONS = ( 280 | "DEBUG=1", 281 | "$(inherited)", 282 | ); 283 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 284 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 285 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 286 | GCC_WARN_UNDECLARED_SELECTOR = YES; 287 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 288 | GCC_WARN_UNUSED_FUNCTION = YES; 289 | GCC_WARN_UNUSED_VARIABLE = YES; 290 | MACOSX_DEPLOYMENT_TARGET = 10.10; 291 | MTL_ENABLE_DEBUG_INFO = YES; 292 | ONLY_ACTIVE_ARCH = YES; 293 | SDKROOT = macosx; 294 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 295 | }; 296 | name = Debug; 297 | }; 298 | E6FFDFBB1A2D831C00125DE8 /* Release */ = { 299 | isa = XCBuildConfiguration; 300 | buildSettings = { 301 | ALWAYS_SEARCH_USER_PATHS = NO; 302 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 303 | CLANG_CXX_LIBRARY = "libc++"; 304 | CLANG_ENABLE_MODULES = YES; 305 | CLANG_ENABLE_OBJC_ARC = YES; 306 | CLANG_WARN_BOOL_CONVERSION = YES; 307 | CLANG_WARN_CONSTANT_CONVERSION = YES; 308 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 309 | CLANG_WARN_EMPTY_BODY = YES; 310 | CLANG_WARN_ENUM_CONVERSION = YES; 311 | CLANG_WARN_INT_CONVERSION = YES; 312 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 313 | CLANG_WARN_UNREACHABLE_CODE = YES; 314 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 315 | CODE_SIGN_IDENTITY = "-"; 316 | COPY_PHASE_STRIP = YES; 317 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 318 | ENABLE_NS_ASSERTIONS = NO; 319 | ENABLE_STRICT_OBJC_MSGSEND = YES; 320 | GCC_C_LANGUAGE_STANDARD = gnu99; 321 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 322 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 323 | GCC_WARN_UNDECLARED_SELECTOR = YES; 324 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 325 | GCC_WARN_UNUSED_FUNCTION = YES; 326 | GCC_WARN_UNUSED_VARIABLE = YES; 327 | MACOSX_DEPLOYMENT_TARGET = 10.10; 328 | MTL_ENABLE_DEBUG_INFO = NO; 329 | SDKROOT = macosx; 330 | }; 331 | name = Release; 332 | }; 333 | E6FFDFBD1A2D831C00125DE8 /* Debug */ = { 334 | isa = XCBuildConfiguration; 335 | buildSettings = { 336 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 337 | COMBINE_HIDPI_IMAGES = YES; 338 | INFOPLIST_FILE = NSSourceListInSwift/Info.plist; 339 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 340 | PRODUCT_BUNDLE_IDENTIFIER = "au.com.electronicinnovations.$(PRODUCT_NAME:rfc1034identifier)"; 341 | PRODUCT_NAME = "$(TARGET_NAME)"; 342 | }; 343 | name = Debug; 344 | }; 345 | E6FFDFBE1A2D831C00125DE8 /* Release */ = { 346 | isa = XCBuildConfiguration; 347 | buildSettings = { 348 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 349 | COMBINE_HIDPI_IMAGES = YES; 350 | INFOPLIST_FILE = NSSourceListInSwift/Info.plist; 351 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 352 | PRODUCT_BUNDLE_IDENTIFIER = "au.com.electronicinnovations.$(PRODUCT_NAME:rfc1034identifier)"; 353 | PRODUCT_NAME = "$(TARGET_NAME)"; 354 | }; 355 | name = Release; 356 | }; 357 | E6FFDFC01A2D831C00125DE8 /* Debug */ = { 358 | isa = XCBuildConfiguration; 359 | buildSettings = { 360 | BUNDLE_LOADER = "$(TEST_HOST)"; 361 | COMBINE_HIDPI_IMAGES = YES; 362 | FRAMEWORK_SEARCH_PATHS = ( 363 | "$(DEVELOPER_FRAMEWORKS_DIR)", 364 | "$(inherited)", 365 | ); 366 | GCC_PREPROCESSOR_DEFINITIONS = ( 367 | "DEBUG=1", 368 | "$(inherited)", 369 | ); 370 | INFOPLIST_FILE = NSSourceListInSwiftTests/Info.plist; 371 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 372 | PRODUCT_BUNDLE_IDENTIFIER = "au.com.electronicinnovations.$(PRODUCT_NAME:rfc1034identifier)"; 373 | PRODUCT_NAME = "$(TARGET_NAME)"; 374 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NSSourceListInSwift.app/Contents/MacOS/NSSourceListInSwift"; 375 | }; 376 | name = Debug; 377 | }; 378 | E6FFDFC11A2D831C00125DE8 /* Release */ = { 379 | isa = XCBuildConfiguration; 380 | buildSettings = { 381 | BUNDLE_LOADER = "$(TEST_HOST)"; 382 | COMBINE_HIDPI_IMAGES = YES; 383 | FRAMEWORK_SEARCH_PATHS = ( 384 | "$(DEVELOPER_FRAMEWORKS_DIR)", 385 | "$(inherited)", 386 | ); 387 | INFOPLIST_FILE = NSSourceListInSwiftTests/Info.plist; 388 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 389 | PRODUCT_BUNDLE_IDENTIFIER = "au.com.electronicinnovations.$(PRODUCT_NAME:rfc1034identifier)"; 390 | PRODUCT_NAME = "$(TARGET_NAME)"; 391 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NSSourceListInSwift.app/Contents/MacOS/NSSourceListInSwift"; 392 | }; 393 | name = Release; 394 | }; 395 | /* End XCBuildConfiguration section */ 396 | 397 | /* Begin XCConfigurationList section */ 398 | E6FFDF9B1A2D831B00125DE8 /* Build configuration list for PBXProject "NSSourceListInSwift" */ = { 399 | isa = XCConfigurationList; 400 | buildConfigurations = ( 401 | E6FFDFBA1A2D831C00125DE8 /* Debug */, 402 | E6FFDFBB1A2D831C00125DE8 /* Release */, 403 | ); 404 | defaultConfigurationIsVisible = 0; 405 | defaultConfigurationName = Release; 406 | }; 407 | E6FFDFBC1A2D831C00125DE8 /* Build configuration list for PBXNativeTarget "NSSourceListInSwift" */ = { 408 | isa = XCConfigurationList; 409 | buildConfigurations = ( 410 | E6FFDFBD1A2D831C00125DE8 /* Debug */, 411 | E6FFDFBE1A2D831C00125DE8 /* Release */, 412 | ); 413 | defaultConfigurationIsVisible = 0; 414 | defaultConfigurationName = Release; 415 | }; 416 | E6FFDFBF1A2D831C00125DE8 /* Build configuration list for PBXNativeTarget "NSSourceListInSwiftTests" */ = { 417 | isa = XCConfigurationList; 418 | buildConfigurations = ( 419 | E6FFDFC01A2D831C00125DE8 /* Debug */, 420 | E6FFDFC11A2D831C00125DE8 /* Release */, 421 | ); 422 | defaultConfigurationIsVisible = 0; 423 | defaultConfigurationName = Release; 424 | }; 425 | /* End XCConfigurationList section */ 426 | }; 427 | rootObject = E6FFDF981A2D831B00125DE8 /* Project object */; 428 | } 429 | -------------------------------------------------------------------------------- /NSSourceListInSwift/NSSourceListInSwift.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NSSourceListInSwift/NSSourceListInSwift/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // NSSourceListInSwift 4 | // 5 | // Created by Daniel Pink on 2/12/2014. 6 | // Copyright (c) 2014 Electronic Innovations. 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 | -------------------------------------------------------------------------------- /NSSourceListInSwift/NSSourceListInSwift/Attributions.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg1252\cocoartf1343\cocoasubrtf160 2 | {\fonttbl\f0\fswiss\fcharset0 Helvetica;} 3 | {\colortbl;\red255\green255\blue255;} 4 | \paperw12240\paperh15840\margl1440\margr1440\vieww9000\viewh8400\viewkind0 5 | \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural 6 | 7 | \f0\fs24 \cf0 Leopard Icon by Adriano Emerick from The Noun Project\ 8 | Lion by Ola M\'f6ller from The Noun Project\ 9 | Tiger by Allison Dominguez from The Noun Project\ 10 | Cat by Daniele Catalanotto / ECAL from The Noun Project\ 11 | Fish by Daniele Catalanotto / ECAL from The Noun Project} -------------------------------------------------------------------------------- /NSSourceListInSwift/NSSourceListInSwift/Images.xcassets/Antigonia.imageset/Artboard 5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/NSOutlineViewInSwift/fc8d60f0139b7b21ba4ee3c42721946982136b23/NSSourceListInSwift/NSSourceListInSwift/Images.xcassets/Antigonia.imageset/Artboard 5.pdf -------------------------------------------------------------------------------- /NSSourceListInSwift/NSSourceListInSwift/Images.xcassets/Antigonia.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Artboard 5.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /NSSourceListInSwift/NSSourceListInSwift/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 | } -------------------------------------------------------------------------------- /NSSourceListInSwift/NSSourceListInSwift/Images.xcassets/Leopard.imageset/Artboard 1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/NSOutlineViewInSwift/fc8d60f0139b7b21ba4ee3c42721946982136b23/NSSourceListInSwift/NSSourceListInSwift/Images.xcassets/Leopard.imageset/Artboard 1.pdf -------------------------------------------------------------------------------- /NSSourceListInSwift/NSSourceListInSwift/Images.xcassets/Leopard.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Artboard 1.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /NSSourceListInSwift/NSSourceListInSwift/Images.xcassets/Lion.imageset/Artboard 2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/NSOutlineViewInSwift/fc8d60f0139b7b21ba4ee3c42721946982136b23/NSSourceListInSwift/NSSourceListInSwift/Images.xcassets/Lion.imageset/Artboard 2.pdf -------------------------------------------------------------------------------- /NSSourceListInSwift/NSSourceListInSwift/Images.xcassets/Lion.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Artboard 2.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /NSSourceListInSwift/NSSourceListInSwift/Images.xcassets/Panthera.imageset/Artboard 4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/NSOutlineViewInSwift/fc8d60f0139b7b21ba4ee3c42721946982136b23/NSSourceListInSwift/NSSourceListInSwift/Images.xcassets/Panthera.imageset/Artboard 4.pdf -------------------------------------------------------------------------------- /NSSourceListInSwift/NSSourceListInSwift/Images.xcassets/Panthera.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Artboard 4.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /NSSourceListInSwift/NSSourceListInSwift/Images.xcassets/Tiger.imageset/Artboard 3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielpi/NSOutlineViewInSwift/fc8d60f0139b7b21ba4ee3c42721946982136b23/NSSourceListInSwift/NSSourceListInSwift/Images.xcassets/Tiger.imageset/Artboard 3.pdf -------------------------------------------------------------------------------- /NSSourceListInSwift/NSSourceListInSwift/Images.xcassets/Tiger.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Artboard 3.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /NSSourceListInSwift/NSSourceListInSwift/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 © 2014 Electronic Innovations. All rights reserved. 29 | NSMainStoryboardFile 30 | Main 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /NSSourceListInSwift/NSSourceListInSwift/Model.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Model.swift 3 | // NSSourceListInSwift 4 | // 5 | // Created by Daniel Pink on 2/12/2014. 6 | // Copyright (c) 2014 Electronic Innovations. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | // It is important that every object in the model that will be 12 | // displayed in the source list can be identified and can be 13 | // used to create the table cell view by itself. 14 | 15 | // This protocol is used to determine how a particular item displays. Since all 16 | // model objects inherit from it, we do not need to perform a case-by-case setup 17 | // of our source table cells. It also makes the model expandable - we can add 18 | // more taxanomical rankings at any time so long as they conform to the protocol. 19 | 20 | protocol SourceListItemDisplayable: class { 21 | var name: String { get } 22 | var icon: NSImage? { get } 23 | func cellID() -> String 24 | func count() -> Int 25 | func childAtIndex(index: Int) -> SourceListItemDisplayable? 26 | } 27 | 28 | // By making count and cellID functions, we can add default implementations to 29 | // the protocol. Any object that implements the protocol but does not implement 30 | // the associated method will use these defaults. This cannot be done with stored 31 | // properties since these cannot be placed into extensions. 32 | 33 | extension SourceListItemDisplayable { 34 | func cellID() -> String { return "DataCell" } 35 | func count() -> Int { return 0 } 36 | func childAtIndex(index: Int) -> SourceListItemDisplayable? { return nil } 37 | } 38 | 39 | // If the model objects don't subclass NSObject the program tends to crash. 40 | 41 | class Life: NSObject, SourceListItemDisplayable { 42 | let name: String 43 | var genus: [Genus] = [] 44 | let icon: NSImage? = nil 45 | 46 | init(name: String) { 47 | self.name = name 48 | super.init() 49 | } 50 | 51 | func cellID() -> String { 52 | return "HeaderCell" 53 | } 54 | 55 | func count() -> Int { 56 | return genus.count 57 | } 58 | 59 | func childAtIndex(index: Int) -> SourceListItemDisplayable? { 60 | return genus[index] 61 | } 62 | } 63 | 64 | class Genus: NSObject, SourceListItemDisplayable { 65 | let name: String 66 | var species: [Species] = [] 67 | let icon: NSImage? 68 | 69 | init(name: String, icon: NSImage?) { 70 | self.name = name 71 | self.icon = icon 72 | super.init() 73 | } 74 | 75 | func count() -> Int { 76 | return species.count 77 | } 78 | 79 | func childAtIndex(index: Int) -> SourceListItemDisplayable? { 80 | return species[index] 81 | } 82 | } 83 | 84 | class Species: NSObject, SourceListItemDisplayable { 85 | let name: String 86 | let genus: Genus 87 | let icon: NSImage? 88 | 89 | init(name: String, icon: NSImage?, genus: Genus) { 90 | self.name = name 91 | self.genus = genus 92 | self.icon = icon 93 | super.init() 94 | genus.species.append(self) 95 | } 96 | } 97 | 98 | 99 | // NOTE: I would personally remove the above model and replace it with something like this: 100 | 101 | enum TaxonomyType { 102 | case Life, Domain, Kingdom, Phylum, Class, Order, Family, Genus, Species 103 | } 104 | 105 | class TaxonomyItem: NSObject { 106 | let name: String 107 | let type: TaxonomyType 108 | let icon: NSImage? 109 | var children = [TaxonomyItem]() 110 | init(name: String, type: TaxonomyType, icon: NSImage?, parent: TaxonomyItem?) { 111 | self.name = name 112 | self.type = type 113 | self.icon = icon 114 | super.init() 115 | 116 | if let parent = parent { 117 | parent.children.append(self) 118 | } 119 | } 120 | } -------------------------------------------------------------------------------- /NSSourceListInSwift/NSSourceListInSwift/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // NSSourceListInSwift 4 | // 5 | // Created by Daniel Pink on 2/12/2014. 6 | // Copyright (c) 2014 Electronic Innovations. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | class ViewController: NSViewController { 12 | 13 | @IBOutlet weak var sourceView: NSOutlineView! 14 | 15 | var fauna = Life(name: "Fauna") 16 | let flora = Life(name: "Flora") 17 | 18 | override func viewDidLoad() { 19 | super.viewDidLoad() 20 | 21 | // Do any additional setup after loading the view. 22 | let panthera = Genus(name: "Panthera", icon: NSImage(named: "Panthera")) 23 | let _ = Species(name: "Lion", icon: NSImage(named: "Lion"), genus: panthera) 24 | let _ = Species(name: "Tiger", icon: NSImage(named: "Tiger"), genus: panthera) 25 | let _ = Species(name: "Leopard", icon: NSImage(named: "Leopard"), genus: panthera) 26 | fauna.genus.append(panthera) 27 | 28 | let antigonia = Genus(name: "Antigonia", icon: NSImage(named:"Antigonia")) 29 | let _ = Species(name: "Capros", icon:nil, genus: antigonia) 30 | let _ = Species(name: "Eos", icon:nil, genus: antigonia) 31 | fauna.genus.append(antigonia) 32 | 33 | let banksia = Genus(name: "Banksia", icon: nil) 34 | let _ = Species(name: "Serrata", icon:nil, genus: banksia) 35 | flora.genus.append(banksia) 36 | 37 | sourceView.expandItem(sourceView.itemAtRow(0)) 38 | sourceView.expandItem(sourceView.itemAtRow(3)) 39 | } 40 | 41 | } 42 | 43 | // MARK:- Outline View Data Source 44 | 45 | extension ViewController: NSOutlineViewDataSource { 46 | 47 | func outlineView(outlineView: NSOutlineView, child index: Int, ofItem item: AnyObject?) -> AnyObject { 48 | guard let item = item else { 49 | switch index { 50 | case 0: return fauna 51 | default: return flora 52 | } 53 | } 54 | 55 | guard let displayable = item as? SourceListItemDisplayable else { 56 | assert(false, "outlineView:index:item: gave a dud item") 57 | return self 58 | } 59 | 60 | guard let child = displayable.childAtIndex(index) else { 61 | assert(false, "outlineView:index:item: gave a dud item") 62 | return self 63 | } 64 | 65 | return child 66 | } 67 | 68 | func outlineView(outlineView: NSOutlineView, isItemExpandable item: AnyObject) -> Bool { 69 | guard let displayable = item as? SourceListItemDisplayable else { return false } 70 | return displayable.count() > 0 71 | } 72 | 73 | func outlineView(outlineView: NSOutlineView, numberOfChildrenOfItem item: AnyObject?) -> Int { 74 | if item == nil { return 2 } 75 | guard let displayable = item as? SourceListItemDisplayable else { return 0 } 76 | return displayable.count() 77 | } 78 | } 79 | 80 | // MARK:- Outline View Delegate 81 | 82 | extension ViewController: NSOutlineViewDelegate { 83 | 84 | func outlineView(outlineView: NSOutlineView, viewForTableColumn: NSTableColumn?, item: AnyObject) -> NSView? { 85 | 86 | // Ensure that the passed item is valid and can be used to create a table cell 87 | guard let displayable = item as? SourceListItemDisplayable, 88 | view = outlineView.makeViewWithIdentifier(displayable.cellID(), owner: self) as? NSTableCellView 89 | else { return nil } 90 | 91 | // If we have a text field, set it to the item's name 92 | if let textField = view.textField { 93 | textField.stringValue = displayable.name 94 | } 95 | 96 | // If we have animage view, set it to the item's icon 97 | if let imageView = view.imageView { 98 | imageView.image = displayable.icon 99 | } 100 | 101 | return view 102 | } 103 | 104 | func outlineView(outlineView: NSOutlineView, shouldSelectItem item: AnyObject) -> Bool { 105 | return !self.outlineView(outlineView, isGroupItem: item) 106 | } 107 | 108 | func outlineView(outlineView: NSOutlineView, isGroupItem item: AnyObject) -> Bool { 109 | return item is Life 110 | } 111 | 112 | } 113 | 114 | -------------------------------------------------------------------------------- /NSSourceListInSwift/NSSourceListInSwiftTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /NSSourceListInSwift/NSSourceListInSwiftTests/NSSourceListInSwiftTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NSSourceListInSwiftTests.swift 3 | // NSSourceListInSwiftTests 4 | // 5 | // Created by Daniel Pink on 2/12/2014. 6 | // Copyright (c) 2014 Electronic Innovations. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import XCTest 11 | 12 | class NSSourceListInSwiftTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | NSOutlineViewInSwift 2 | ==================== 3 | 4 | A project to help me understand what is required to provide data for an NSOutlineView control 5 | 6 | First up I'll try to get the File system example from the Outline View Programming Guide. 7 | 8 | ## NSOutlineViewInSwift Project 9 | 10 | Option | Setting 11 | ---------- | ----- 12 | Table Type | NSOutlineView 13 | Content View | Cell Based 14 | Language | Swift 15 | IB Method | Storyboard 16 | Example from | [Outline View Programming Topics](https://developer.apple.com/library/mac/Documentation/Cocoa/Conceptual/OutlineView/OutlineView.html) 17 | 18 | 19 | Steps followed to create the demo (Using Mac OS X Yosemite 10.10.1 and XCode 6) 20 | - Created a new Swift project (Using storyboards cause I like them) 21 | - Add a source list to the content view that has already been created (it is controlled by the ViewController class that has also already been created by the template). 22 | - Mark the ViewController as conforming to the NSOutlineViewDelegate and NSOutlineViewDataSource protocols 23 | - Back in IB link the NSOutlineView datasource and delegate outlets to the view controller (blue circle with white square inside that is at the top of the view) 24 | - Create a new Cocoa class that is a subclass of NSObject. Name it FileSystemItem. 25 | - Convert the Objective-C code from the example over to Swift. This was moderately tricky as the concepts between the two languages sometimes clash. I have tried to keep the code as close to the original as possible for now (though I will likely try and change it to more Swift like idioms once I understand the code better). 26 | - Back in the View Controller I implemented the minimum set of data source methods, the method signatures are shown below in Swift. 27 | 28 | func outlineView(outlineView: NSOutlineView, 29 | child index: Int, 30 | ofItem item: AnyObject?) -> AnyObject { } 31 | 32 | func outlineView(outlineView: NSOutlineView, 33 | isItemExpandable item: AnyObject) -> Bool { } 34 | 35 | func outlineView(outlineView: NSOutlineView, 36 | numberOfChildrenOfItem item: AnyObject?) -> Int { } 37 | 38 | func outlineView(outlineView: NSOutlineView, 39 | objectValueForTableColumn: NSTableColumn?, 40 | byItem:AnyObject?) -> AnyObject? { } 41 | 42 | - With all that code filled in the application should run and should try to fill the NSOutlineView in with data. Unfortunately it won't get the path names right because by default the NSOutline view will be set to view based mode where as the example assumes cell based mode. 43 | - In IB select the NSOutlineView (3 clicks). In the Attributes Inspector you can set the Content mode to Cell Based. 44 | 45 | Now the application should run and show you the file system in the outline view. 46 | 47 | 48 | ## NSOutlineViewUsingViewMode Project 49 | 50 | Option | Setting 51 | ---------- | ----- 52 | Table Type | NSOutlineView 53 | Content View | View Based 54 | Language | Swift 55 | IB Method | Storyboard 56 | Example from | [Outline View Programming Topics](https://developer.apple.com/library/mac/Documentation/Cocoa/Conceptual/OutlineView/OutlineView.html) 57 | 58 | There is a version of the same program which uses a view based outline view instead of a cell based view. It should operate exactly the same despite this difference. What needed to be changed between the two programs is listed below 59 | 60 | - In IB set the Content Mode for the Outline View to View Based (this is the default) 61 | - The datasource method objectValueForTableColumn: is no longer used. Instead the delegate method viewForTableColumn: is used to generate the content in each row/column. Inside this method we need to create a view to be displayed using makeViewWithIdentifier (look up NSTableView to find it). 62 | - In IB you need to set the Identifier for your NSTableCellView to the string that you used in makeViewWithIdentifier (something like "DataCell") 63 | 64 | The application should then run the same as the Cell based version. 65 | 66 | 67 | ## NSSourceListInSwift Project 68 | 69 | Option | Setting 70 | ---------- | ----- 71 | Table Type | Source List (NSOutlineView) 72 | Content View | View Based 73 | Language | Swift 74 | IB Method | Storyboard 75 | Example from | Me 76 | 77 | Source list views are a little different from regular NSOutlineViews because they are often used to display groups of quite different objects. For instance in the Finder we have Favourites (Finder folders), Devices, Shared and Tags are all shown in the one Source List. For this reason I feel we should be able to map very different model objects into a source list without making everything come from the same base ItemClass. This has proven to be quite difficult for me to master. 78 | 79 | Some of the issues and points of interest are 80 | - It is important that every object in the model that will be displayed in the source list can be identified and can be used to create a table cell view by itself. The Genus and Species class in the project are good examples, the fauna array in the ViewController is a bad example (because it is hard to identify it from another array when it is passed in to the datasource methods). 81 | - If the model objects don't subclass NSObject the program tends to crash. 82 | - You can use arrays as the top container classes of your source list groupings, but it probably isn't a good idea. If you do (as I have done in this example) then you should use NSMutableArray rather than Swift arrays (it would crash for me using swift arrays). 83 | - You can set the rows to display as group items which have a show/hide button rather than a reveal triangle by implementing the *func outlineView(outlineView: NSOutlineView, isGroupItem item: AnyObject) -> Bool* delegate method (Thanks to [@cliftonlabrum](https://twitter.com/cliftonlabrum) for pointing that out). 84 | --------------------------------------------------------------------------------