├── CollectionViewElCapitan.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── klaas.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── klaas.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── CollectionViewElCapitan.xcscheme │ └── xcschememanagement.plist ├── CollectionViewElCapitan ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ └── Main.storyboard ├── Info.plist ├── LabelCollectionViewItem.swift ├── LabelCollectionViewItem.xib ├── LabelCollectionViewItemView.swift ├── NSView+AutoLayout.swift └── ViewController.swift └── README.md /CollectionViewElCapitan.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 4AB7DD051BC52289003661BF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AB7DD041BC52289003661BF /* AppDelegate.swift */; }; 11 | 4AB7DD071BC52289003661BF /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AB7DD061BC52289003661BF /* ViewController.swift */; }; 12 | 4AB7DD091BC52289003661BF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4AB7DD081BC52289003661BF /* Assets.xcassets */; }; 13 | 4AB7DD0C1BC52289003661BF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4AB7DD0A1BC52289003661BF /* Main.storyboard */; }; 14 | 4AB7DD161BC522F2003661BF /* LabelCollectionViewItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AB7DD131BC522F2003661BF /* LabelCollectionViewItem.swift */; }; 15 | 4AB7DD171BC522F2003661BF /* LabelCollectionViewItem.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4AB7DD141BC522F2003661BF /* LabelCollectionViewItem.xib */; }; 16 | 4AB7DD181BC522F2003661BF /* LabelCollectionViewItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AB7DD151BC522F2003661BF /* LabelCollectionViewItemView.swift */; }; 17 | 4AE776A21CC8E9780002CD33 /* NSView+AutoLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AE776A11CC8E9780002CD33 /* NSView+AutoLayout.swift */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXFileReference section */ 21 | 4AB7DD011BC52289003661BF /* CollectionViewElCapitan.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CollectionViewElCapitan.app; sourceTree = BUILT_PRODUCTS_DIR; }; 22 | 4AB7DD041BC52289003661BF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 23 | 4AB7DD061BC52289003661BF /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 24 | 4AB7DD081BC52289003661BF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 25 | 4AB7DD0B1BC52289003661BF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 26 | 4AB7DD0D1BC52289003661BF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 27 | 4AB7DD131BC522F2003661BF /* LabelCollectionViewItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelCollectionViewItem.swift; sourceTree = ""; }; 28 | 4AB7DD141BC522F2003661BF /* LabelCollectionViewItem.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LabelCollectionViewItem.xib; sourceTree = ""; }; 29 | 4AB7DD151BC522F2003661BF /* LabelCollectionViewItemView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelCollectionViewItemView.swift; sourceTree = ""; }; 30 | 4AE776A11CC8E9780002CD33 /* NSView+AutoLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSView+AutoLayout.swift"; sourceTree = ""; }; 31 | /* End PBXFileReference section */ 32 | 33 | /* Begin PBXFrameworksBuildPhase section */ 34 | 4AB7DCFE1BC52289003661BF /* Frameworks */ = { 35 | isa = PBXFrameworksBuildPhase; 36 | buildActionMask = 2147483647; 37 | files = ( 38 | ); 39 | runOnlyForDeploymentPostprocessing = 0; 40 | }; 41 | /* End PBXFrameworksBuildPhase section */ 42 | 43 | /* Begin PBXGroup section */ 44 | 4AB7DCF81BC52289003661BF = { 45 | isa = PBXGroup; 46 | children = ( 47 | 4AB7DD031BC52289003661BF /* CollectionViewElCapitan */, 48 | 4AB7DD021BC52289003661BF /* Products */, 49 | ); 50 | sourceTree = ""; 51 | }; 52 | 4AB7DD021BC52289003661BF /* Products */ = { 53 | isa = PBXGroup; 54 | children = ( 55 | 4AB7DD011BC52289003661BF /* CollectionViewElCapitan.app */, 56 | ); 57 | name = Products; 58 | sourceTree = ""; 59 | }; 60 | 4AB7DD031BC52289003661BF /* CollectionViewElCapitan */ = { 61 | isa = PBXGroup; 62 | children = ( 63 | 4AE776A11CC8E9780002CD33 /* NSView+AutoLayout.swift */, 64 | 4AB7DD131BC522F2003661BF /* LabelCollectionViewItem.swift */, 65 | 4AB7DD151BC522F2003661BF /* LabelCollectionViewItemView.swift */, 66 | 4AB7DD141BC522F2003661BF /* LabelCollectionViewItem.xib */, 67 | 4AB7DD041BC52289003661BF /* AppDelegate.swift */, 68 | 4AB7DD061BC52289003661BF /* ViewController.swift */, 69 | 4AB7DD081BC52289003661BF /* Assets.xcassets */, 70 | 4AB7DD0A1BC52289003661BF /* Main.storyboard */, 71 | 4AB7DD0D1BC52289003661BF /* Info.plist */, 72 | ); 73 | path = CollectionViewElCapitan; 74 | sourceTree = ""; 75 | }; 76 | /* End PBXGroup section */ 77 | 78 | /* Begin PBXNativeTarget section */ 79 | 4AB7DD001BC52289003661BF /* CollectionViewElCapitan */ = { 80 | isa = PBXNativeTarget; 81 | buildConfigurationList = 4AB7DD101BC52289003661BF /* Build configuration list for PBXNativeTarget "CollectionViewElCapitan" */; 82 | buildPhases = ( 83 | 4AB7DCFD1BC52289003661BF /* Sources */, 84 | 4AB7DCFE1BC52289003661BF /* Frameworks */, 85 | 4AB7DCFF1BC52289003661BF /* Resources */, 86 | ); 87 | buildRules = ( 88 | ); 89 | dependencies = ( 90 | ); 91 | name = CollectionViewElCapitan; 92 | productName = CollectionViewElCapitan; 93 | productReference = 4AB7DD011BC52289003661BF /* CollectionViewElCapitan.app */; 94 | productType = "com.apple.product-type.application"; 95 | }; 96 | /* End PBXNativeTarget section */ 97 | 98 | /* Begin PBXProject section */ 99 | 4AB7DCF91BC52289003661BF /* Project object */ = { 100 | isa = PBXProject; 101 | attributes = { 102 | LastUpgradeCheck = 0700; 103 | ORGANIZATIONNAME = "Park Bench"; 104 | TargetAttributes = { 105 | 4AB7DD001BC52289003661BF = { 106 | CreatedOnToolsVersion = 7.0.1; 107 | }; 108 | }; 109 | }; 110 | buildConfigurationList = 4AB7DCFC1BC52289003661BF /* Build configuration list for PBXProject "CollectionViewElCapitan" */; 111 | compatibilityVersion = "Xcode 3.2"; 112 | developmentRegion = English; 113 | hasScannedForEncodings = 0; 114 | knownRegions = ( 115 | en, 116 | Base, 117 | ); 118 | mainGroup = 4AB7DCF81BC52289003661BF; 119 | productRefGroup = 4AB7DD021BC52289003661BF /* Products */; 120 | projectDirPath = ""; 121 | projectRoot = ""; 122 | targets = ( 123 | 4AB7DD001BC52289003661BF /* CollectionViewElCapitan */, 124 | ); 125 | }; 126 | /* End PBXProject section */ 127 | 128 | /* Begin PBXResourcesBuildPhase section */ 129 | 4AB7DCFF1BC52289003661BF /* Resources */ = { 130 | isa = PBXResourcesBuildPhase; 131 | buildActionMask = 2147483647; 132 | files = ( 133 | 4AB7DD171BC522F2003661BF /* LabelCollectionViewItem.xib in Resources */, 134 | 4AB7DD091BC52289003661BF /* Assets.xcassets in Resources */, 135 | 4AB7DD0C1BC52289003661BF /* Main.storyboard in Resources */, 136 | ); 137 | runOnlyForDeploymentPostprocessing = 0; 138 | }; 139 | /* End PBXResourcesBuildPhase section */ 140 | 141 | /* Begin PBXSourcesBuildPhase section */ 142 | 4AB7DCFD1BC52289003661BF /* Sources */ = { 143 | isa = PBXSourcesBuildPhase; 144 | buildActionMask = 2147483647; 145 | files = ( 146 | 4AE776A21CC8E9780002CD33 /* NSView+AutoLayout.swift in Sources */, 147 | 4AB7DD181BC522F2003661BF /* LabelCollectionViewItemView.swift in Sources */, 148 | 4AB7DD071BC52289003661BF /* ViewController.swift in Sources */, 149 | 4AB7DD051BC52289003661BF /* AppDelegate.swift in Sources */, 150 | 4AB7DD161BC522F2003661BF /* LabelCollectionViewItem.swift in Sources */, 151 | ); 152 | runOnlyForDeploymentPostprocessing = 0; 153 | }; 154 | /* End PBXSourcesBuildPhase section */ 155 | 156 | /* Begin PBXVariantGroup section */ 157 | 4AB7DD0A1BC52289003661BF /* Main.storyboard */ = { 158 | isa = PBXVariantGroup; 159 | children = ( 160 | 4AB7DD0B1BC52289003661BF /* Base */, 161 | ); 162 | name = Main.storyboard; 163 | sourceTree = ""; 164 | }; 165 | /* End PBXVariantGroup section */ 166 | 167 | /* Begin XCBuildConfiguration section */ 168 | 4AB7DD0E1BC52289003661BF /* Debug */ = { 169 | isa = XCBuildConfiguration; 170 | buildSettings = { 171 | ALWAYS_SEARCH_USER_PATHS = NO; 172 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 173 | CLANG_CXX_LIBRARY = "libc++"; 174 | CLANG_ENABLE_MODULES = YES; 175 | CLANG_ENABLE_OBJC_ARC = YES; 176 | CLANG_WARN_BOOL_CONVERSION = YES; 177 | CLANG_WARN_CONSTANT_CONVERSION = YES; 178 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 179 | CLANG_WARN_EMPTY_BODY = YES; 180 | CLANG_WARN_ENUM_CONVERSION = YES; 181 | CLANG_WARN_INT_CONVERSION = YES; 182 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 183 | CLANG_WARN_UNREACHABLE_CODE = YES; 184 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 185 | CODE_SIGN_IDENTITY = "-"; 186 | COPY_PHASE_STRIP = NO; 187 | DEBUG_INFORMATION_FORMAT = dwarf; 188 | ENABLE_STRICT_OBJC_MSGSEND = YES; 189 | ENABLE_TESTABILITY = YES; 190 | GCC_C_LANGUAGE_STANDARD = gnu99; 191 | GCC_DYNAMIC_NO_PIC = NO; 192 | GCC_NO_COMMON_BLOCKS = YES; 193 | GCC_OPTIMIZATION_LEVEL = 0; 194 | GCC_PREPROCESSOR_DEFINITIONS = ( 195 | "DEBUG=1", 196 | "$(inherited)", 197 | ); 198 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 199 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 200 | GCC_WARN_UNDECLARED_SELECTOR = YES; 201 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 202 | GCC_WARN_UNUSED_FUNCTION = YES; 203 | GCC_WARN_UNUSED_VARIABLE = YES; 204 | MACOSX_DEPLOYMENT_TARGET = 10.11; 205 | MTL_ENABLE_DEBUG_INFO = YES; 206 | ONLY_ACTIVE_ARCH = YES; 207 | SDKROOT = macosx; 208 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 209 | }; 210 | name = Debug; 211 | }; 212 | 4AB7DD0F1BC52289003661BF /* Release */ = { 213 | isa = XCBuildConfiguration; 214 | buildSettings = { 215 | ALWAYS_SEARCH_USER_PATHS = NO; 216 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 217 | CLANG_CXX_LIBRARY = "libc++"; 218 | CLANG_ENABLE_MODULES = YES; 219 | CLANG_ENABLE_OBJC_ARC = YES; 220 | CLANG_WARN_BOOL_CONVERSION = YES; 221 | CLANG_WARN_CONSTANT_CONVERSION = YES; 222 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 223 | CLANG_WARN_EMPTY_BODY = YES; 224 | CLANG_WARN_ENUM_CONVERSION = YES; 225 | CLANG_WARN_INT_CONVERSION = YES; 226 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 227 | CLANG_WARN_UNREACHABLE_CODE = YES; 228 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 229 | CODE_SIGN_IDENTITY = "-"; 230 | COPY_PHASE_STRIP = NO; 231 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 232 | ENABLE_NS_ASSERTIONS = NO; 233 | ENABLE_STRICT_OBJC_MSGSEND = YES; 234 | GCC_C_LANGUAGE_STANDARD = gnu99; 235 | GCC_NO_COMMON_BLOCKS = YES; 236 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 237 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 238 | GCC_WARN_UNDECLARED_SELECTOR = YES; 239 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 240 | GCC_WARN_UNUSED_FUNCTION = YES; 241 | GCC_WARN_UNUSED_VARIABLE = YES; 242 | MACOSX_DEPLOYMENT_TARGET = 10.11; 243 | MTL_ENABLE_DEBUG_INFO = NO; 244 | SDKROOT = macosx; 245 | }; 246 | name = Release; 247 | }; 248 | 4AB7DD111BC52289003661BF /* Debug */ = { 249 | isa = XCBuildConfiguration; 250 | buildSettings = { 251 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 252 | COMBINE_HIDPI_IMAGES = YES; 253 | INFOPLIST_FILE = CollectionViewElCapitan/Info.plist; 254 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 255 | PRODUCT_BUNDLE_IDENTIFIER = eu.parkbench.CollectionViewElCapitan; 256 | PRODUCT_NAME = "$(TARGET_NAME)"; 257 | }; 258 | name = Debug; 259 | }; 260 | 4AB7DD121BC52289003661BF /* Release */ = { 261 | isa = XCBuildConfiguration; 262 | buildSettings = { 263 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 264 | COMBINE_HIDPI_IMAGES = YES; 265 | INFOPLIST_FILE = CollectionViewElCapitan/Info.plist; 266 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 267 | PRODUCT_BUNDLE_IDENTIFIER = eu.parkbench.CollectionViewElCapitan; 268 | PRODUCT_NAME = "$(TARGET_NAME)"; 269 | }; 270 | name = Release; 271 | }; 272 | /* End XCBuildConfiguration section */ 273 | 274 | /* Begin XCConfigurationList section */ 275 | 4AB7DCFC1BC52289003661BF /* Build configuration list for PBXProject "CollectionViewElCapitan" */ = { 276 | isa = XCConfigurationList; 277 | buildConfigurations = ( 278 | 4AB7DD0E1BC52289003661BF /* Debug */, 279 | 4AB7DD0F1BC52289003661BF /* Release */, 280 | ); 281 | defaultConfigurationIsVisible = 0; 282 | defaultConfigurationName = Release; 283 | }; 284 | 4AB7DD101BC52289003661BF /* Build configuration list for PBXNativeTarget "CollectionViewElCapitan" */ = { 285 | isa = XCConfigurationList; 286 | buildConfigurations = ( 287 | 4AB7DD111BC52289003661BF /* Debug */, 288 | 4AB7DD121BC52289003661BF /* Release */, 289 | ); 290 | defaultConfigurationIsVisible = 0; 291 | defaultConfigurationName = Release; 292 | }; 293 | /* End XCConfigurationList section */ 294 | }; 295 | rootObject = 4AB7DCF91BC52289003661BF /* Project object */; 296 | } 297 | -------------------------------------------------------------------------------- /CollectionViewElCapitan.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CollectionViewElCapitan.xcodeproj/project.xcworkspace/xcuserdata/klaas.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klaas/CollectionViewElCapitan/8c9d355e53aa0c5fde45b5df35c9562055a4e667/CollectionViewElCapitan.xcodeproj/project.xcworkspace/xcuserdata/klaas.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /CollectionViewElCapitan.xcodeproj/xcuserdata/klaas.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /CollectionViewElCapitan.xcodeproj/xcuserdata/klaas.xcuserdatad/xcschemes/CollectionViewElCapitan.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /CollectionViewElCapitan.xcodeproj/xcuserdata/klaas.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CollectionViewElCapitan.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4AB7DD001BC52289003661BF 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /CollectionViewElCapitan/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // CollectionViewElCapitan 4 | // 5 | // Created by Klaas on 07.10.15. 6 | // Copyright © 2015 Park Bench. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | @NSApplicationMain 12 | class AppDelegate: NSObject, NSApplicationDelegate { 13 | 14 | func applicationDidFinishLaunching(aNotification: NSNotification) { 15 | // Insert code here to initialize your application 16 | } 17 | 18 | func applicationWillTerminate(aNotification: NSNotification) { 19 | // Insert code here to tear down your application 20 | } 21 | 22 | 23 | } 24 | 25 | -------------------------------------------------------------------------------- /CollectionViewElCapitan/Assets.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 | } -------------------------------------------------------------------------------- /CollectionViewElCapitan/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | Default 511 | 512 | 513 | 514 | 515 | 516 | 517 | Left to Right 518 | 519 | 520 | 521 | 522 | 523 | 524 | Right to Left 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | Default 536 | 537 | 538 | 539 | 540 | 541 | 542 | Left to Right 543 | 544 | 545 | 546 | 547 | 548 | 549 | Right to Left 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 | 699 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | -------------------------------------------------------------------------------- /CollectionViewElCapitan/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSHumanReadableCopyright 28 | Copyright © 2015 Park Bench. All rights reserved. 29 | NSMainStoryboardFile 30 | Main 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /CollectionViewElCapitan/LabelCollectionViewItem.swift: -------------------------------------------------------------------------------- 1 | // 2 | 3 | import Foundation 4 | import AppKit 5 | 6 | class LabelObject: NSObject { 7 | var title:String 8 | 9 | init(title:String) { 10 | self.title = title 11 | } 12 | } 13 | 14 | 15 | class LabelCollectionViewItem: NSCollectionViewItem { 16 | 17 | // MARK: properties 18 | 19 | var labelObject:LabelObject? { 20 | return representedObject as? LabelObject 21 | } 22 | 23 | override var selected: Bool { 24 | didSet { 25 | (self.view as! LabelCollectionViewItemView).selected = selected 26 | } 27 | } 28 | override var highlightState: NSCollectionViewItemHighlightState { 29 | didSet { 30 | (self.view as! LabelCollectionViewItemView).highlightState = highlightState 31 | } 32 | } 33 | 34 | // MARK: outlets 35 | 36 | @IBOutlet weak var label: NSTextField! 37 | 38 | // MARK: NSResponder 39 | 40 | override func mouseDown(theEvent: NSEvent) { 41 | if theEvent.clickCount == 2 { 42 | print("Double click \(labelObject!.title)") 43 | } else { 44 | super.mouseDown(theEvent) 45 | } 46 | 47 | } 48 | 49 | } 50 | 51 | class LabelCollectionViewItem2: NSCollectionViewItem { 52 | 53 | // MARK: properties 54 | 55 | var labelObject:LabelObject? { 56 | didSet { 57 | label.stringValue = labelObject?.title ?? "" 58 | } 59 | } 60 | 61 | override var selected: Bool { 62 | didSet { 63 | (self.view as! LabelCollectionViewItemView).selected = selected 64 | } 65 | } 66 | override var highlightState: NSCollectionViewItemHighlightState { 67 | didSet { 68 | (self.view as! LabelCollectionViewItemView).highlightState = highlightState 69 | } 70 | } 71 | 72 | // MARK: - 🔴🔴🔴🔴🔴 view properties 🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴 73 | 74 | var label:NSTextField! 75 | 76 | // MARK: - 🔴🔴🔴🔴🔴 NSViewController 🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴 77 | 78 | override func loadView() { 79 | self.view = LabelCollectionViewItemView(frame: NSRect(x: 0, y: 0, width: 300, height: 30)) 80 | self.view.wantsLayer = true 81 | self.view.layer?.backgroundColor = NSColor.greenColor().CGColor 82 | 83 | label = { 84 | let v = NSTextField() 85 | v.selectable = false 86 | v.editable = false 87 | v.drawsBackground = false 88 | v.bezeled = false 89 | v.translatesAutoresizingMaskIntoConstraints = false 90 | v.alignment = .Center 91 | v.font = NSFont.systemFontOfSize(30) 92 | return v 93 | }() 94 | 95 | self.view.addSubview(label) 96 | self.view.pbbPlaceInCenter(label) 97 | } 98 | 99 | // MARK: NSResponder 100 | 101 | override func mouseDown(theEvent: NSEvent) { 102 | if theEvent.clickCount == 2 { 103 | print("Double click \(labelObject!.title)") 104 | } else { 105 | super.mouseDown(theEvent) 106 | } 107 | 108 | } 109 | 110 | } 111 | 112 | -------------------------------------------------------------------------------- /CollectionViewElCapitan/LabelCollectionViewItem.xib: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /CollectionViewElCapitan/LabelCollectionViewItemView.swift: -------------------------------------------------------------------------------- 1 | // 2 | 3 | import Foundation 4 | import AppKit 5 | 6 | class LabelCollectionViewItemView: NSView { 7 | 8 | // MARK: properties 9 | 10 | var selected: Bool = false { 11 | didSet { 12 | if selected != oldValue { 13 | needsDisplay = true 14 | } 15 | } 16 | } 17 | var highlightState: NSCollectionViewItemHighlightState = .None { 18 | didSet { 19 | if highlightState != oldValue { 20 | needsDisplay = true 21 | } 22 | } 23 | } 24 | 25 | // MARK: NSView 26 | 27 | override var wantsUpdateLayer: Bool { 28 | return true 29 | } 30 | 31 | override func updateLayer() { 32 | if selected { 33 | self.layer?.cornerRadius = 10 34 | layer!.backgroundColor = NSColor.darkGrayColor().CGColor 35 | } else { 36 | self.layer?.cornerRadius = 0 37 | layer!.backgroundColor = NSColor.lightGrayColor().CGColor 38 | } 39 | 40 | } 41 | 42 | // MARK: init 43 | 44 | override init(frame frameRect: NSRect) { 45 | super.init(frame: frameRect) 46 | wantsLayer = true 47 | layer?.masksToBounds = true 48 | } 49 | 50 | required init?(coder: NSCoder) { 51 | super.init(coder: coder) 52 | wantsLayer = true 53 | layer?.masksToBounds = true 54 | } 55 | } -------------------------------------------------------------------------------- /CollectionViewElCapitan/NSView+AutoLayout.swift: -------------------------------------------------------------------------------- 1 | // 2 | 3 | import Foundation 4 | import AppKit 5 | 6 | // -------------------------------------------------------------------------------- 7 | // auto layout 8 | // -------------------------------------------------------------------------------- 9 | 10 | extension NSView { 11 | public func pbbPlace(view: NSView, inset:CGFloat) -> [NSLayoutConstraint] { 12 | return pbbPlace(view, at:(inset, inset, inset, inset)) 13 | } 14 | 15 | public func pbbPlace(view: NSView, at tuple:(CGFloat?, CGFloat?, CGFloat?, CGFloat?) = (0,0,0,0)) -> [NSLayoutConstraint] { 16 | var res: [NSLayoutConstraint] = [] 17 | 18 | let (top, left, bottom, right) = tuple 19 | 20 | if let inset = top { 21 | let c = NSLayoutConstraint( item: view, attribute: .Top, relatedBy: .Equal, toItem: self, attribute: .Top, multiplier: 1.0, constant: inset) 22 | res.append(c) 23 | } 24 | if let inset = left { 25 | let c = NSLayoutConstraint( item: view, attribute: .Left, relatedBy: .Equal, toItem: self, attribute: .Left, multiplier: 1.0, constant: inset) 26 | res.append(c) 27 | } 28 | if let inset = bottom { 29 | let c = NSLayoutConstraint( item: self, attribute: .Bottom, relatedBy: .Equal, toItem: view, attribute: .Bottom, multiplier: 1.0, constant: inset) 30 | res.append(c) 31 | } 32 | if let inset = right { 33 | let c = NSLayoutConstraint( item: self, attribute: .Right, relatedBy: .Equal, toItem: view, attribute: .Right, multiplier: 1.0, constant: inset) 34 | res.append(c) 35 | } 36 | 37 | addConstraints(res) 38 | 39 | return res 40 | } 41 | 42 | public func pbbPlaceInCenter(view:NSView, withOffset offset:(CGFloat, CGFloat) = (0,0)) -> [NSLayoutConstraint] { 43 | let c1 = NSLayoutConstraint( item: view, attribute: .CenterX, relatedBy: .Equal, toItem: self, attribute: .CenterX, multiplier: 1.0, constant: offset.0) 44 | let c2 = NSLayoutConstraint( item: view, attribute: .CenterY, relatedBy: .Equal, toItem: self, attribute: .CenterY, multiplier: 1.0, constant: offset.1) 45 | 46 | addConstraints([c1, c2]) 47 | 48 | return [c1, c2] 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /CollectionViewElCapitan/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // CollectionViewElCapitan 4 | // 5 | // Created by Klaas on 07.10.15. 6 | // Copyright © 2015 Park Bench. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | class ViewController: NSViewController, NSCollectionViewDataSource { 12 | var strings = ["Peter", "Florian", "Ruediger", "John", "Paul", "George", "Ringo"].sort() 13 | 14 | @IBOutlet weak var collectionView: NSCollectionView! 15 | private var collectionView2:NSCollectionView! 16 | private var scrollView:NSScrollView! 17 | 18 | override func viewDidLoad() { 19 | super.viewDidLoad() 20 | 21 | // MARK: - 🔴🔴🔴🔴🔴 parte 1: interface builder 🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴 22 | 23 | collectionView.dataSource = self 24 | collectionView.registerClass(LabelCollectionViewItem2.self, forItemWithIdentifier: "item") 25 | 26 | // MARK: - 🔴🔴🔴🔴🔴 part 2: programmatically 🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴 27 | 28 | scrollView = { 29 | let v = NSScrollView(frame: NSRect.zero) 30 | v.translatesAutoresizingMaskIntoConstraints = false 31 | v.hasVerticalRuler = false 32 | v.hasVerticalScroller = true 33 | return v 34 | }() 35 | 36 | collectionView2 = { 37 | let v = NSCollectionView(frame: NSRect.zero) 38 | v.wantsLayer = true 39 | v.layer!.backgroundColor = NSColor.brownColor().CGColor 40 | v.selectable = true 41 | v.allowsEmptySelection = false 42 | v.collectionViewLayout = { 43 | let l = NSCollectionViewFlowLayout() 44 | l.minimumInteritemSpacing = 10 45 | l.minimumLineSpacing = 10 46 | l.scrollDirection = NSCollectionViewScrollDirection.Horizontal 47 | l.sectionInset = NSEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) 48 | l.itemSize = CGSize(width: 400, height: 80) 49 | return l 50 | }() 51 | 52 | return v 53 | }() 54 | 55 | collectionView2.registerClass(LabelCollectionViewItem2.self, forItemWithIdentifier: "item") 56 | collectionView2.dataSource = self 57 | scrollView.documentView = collectionView2 58 | 59 | view.addSubview(scrollView) 60 | 61 | view.pbbPlace(scrollView, at:(300,0,0,0)) 62 | } 63 | 64 | // MARK: NSCollectionViewDataSource 65 | 66 | func collectionView(collectionView: NSCollectionView, numberOfItemsInSection section: Int) -> Int { 67 | return strings.count * 10 68 | } 69 | 70 | func collectionView(collectionView: NSCollectionView, itemForRepresentedObjectAtIndexPath indexPath: NSIndexPath) -> NSCollectionViewItem { 71 | 72 | let lo = LabelObject(title: strings[indexPath.item % strings.count]) 73 | 74 | if indexPath.item % 2 == 0 { 75 | let item = collectionView.makeItemWithIdentifier("item", forIndexPath: indexPath) as! LabelCollectionViewItem2 76 | item.labelObject = lo 77 | return item 78 | } else { 79 | let item = collectionView.makeItemWithIdentifier("LabelCollectionViewItem", forIndexPath: indexPath) 80 | item.representedObject = lo 81 | return item 82 | } 83 | 84 | } 85 | } 86 | 87 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 🚨 **This is a Swift 2 repo. The updated version: ** 🚨 2 | 3 | # CollectionViewElCapitan 4 | Apple changed the way `NSCollectionView` works in OS 10.11 as shown in the talk ["What's New in NSCollectionView"](https://developer.apple.com/videos/play/wwdc2015-225/) at WWDC 2015. They also provide a complex example written in Objective-C: [CocoaSlideCollection](https://developer.apple.com/library/mac/samplecode/CocoaSlideCollection/Introduction/Intro.html) 5 | 6 | This is a simple sample project written in Swift. 7 | 8 | It uses the standard Cocoa Application template and has a single view controller containing a collection view. It shows simple labels as items. You can select and double click items. 9 | 10 | ### Notes 11 | 12 | There is still a bug in Xcode (as of 7.3 (7D175)): When you add a NSCollectionView within Interface Bulider you'll get a compile error saying: 13 | 14 | `Main.storyboard: error: Unknown segue relationship: Prototype` 15 | 16 | The workaround used in this project is to remove the segue and create a .xib file containing the collection view item. The filename can then be used as an item identifier. 17 | 18 | ### Programmatic Version 19 | 20 | The branch `ProgrammaticVersion` contains a second `NSCollectionView` that does not rely on any Interface Builder files. 21 | --------------------------------------------------------------------------------