├── .gitignore ├── .travis.yml ├── ACReuseQueue.podspec ├── ACReuseQueue.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── ACReuseQueue ├── ACReusableObject.h ├── ACReuseQueue-Prefix.pch ├── ACReuseQueue.h └── ACReuseQueue.m ├── ACReuseQueueDemo ├── ACAppDelegate.h ├── ACAppDelegate.m ├── ACButton.h ├── ACButton.m ├── ACButton.xib ├── ACDataViewController.h ├── ACDataViewController.m ├── ACPageViewController.h ├── ACPageViewController.m ├── ACReuseQueueDemo-Info.plist ├── ACReuseQueueDemo-Prefix.pch ├── ACTableViewController.h ├── ACTableViewController.m ├── Base.lproj │ └── Main_iPhone.storyboard ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json ├── en.lproj │ └── InfoPlist.strings └── main.m ├── ACReuseQueueTests ├── ACReusableTest.xib ├── ACReusableTestObject.h ├── ACReusableTestObject.m ├── ACReuseQueueTests-Info.plist ├── ACReuseQueueTests.m └── en.lproj │ └── InfoPlist.strings ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | ######################### 2 | # .gitignore file for Xcode4 / OS X Source projects 3 | # 4 | # Version 2.0 5 | # For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects 6 | # 7 | # 2013 updates: 8 | # - fixed the broken "save personal Schemes" 9 | # 10 | # NB: if you are storing "built" products, this WILL NOT WORK, 11 | # and you should use a different .gitignore (or none at all) 12 | # This file is for SOURCE projects, where there are many extra 13 | # files that we want to exclude 14 | # 15 | ######################### 16 | 17 | ##### 18 | # OS X temporary files that should never be committed 19 | 20 | .DS_Store 21 | *.swp 22 | *.lock 23 | profile 24 | 25 | 26 | #### 27 | # Xcode temporary files that should never be committed 28 | # 29 | # NB: NIB/XIB files still exist even on Storyboard projects, so we want this... 30 | 31 | *~.nib 32 | 33 | 34 | #### 35 | # Xcode build files - 36 | # 37 | # NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "DerivedData" 38 | 39 | DerivedData/ 40 | 41 | # NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "build" 42 | 43 | build/ 44 | 45 | 46 | ##### 47 | # Xcode private settings (window sizes, bookmarks, breakpoints, custom executables, smart groups) 48 | # 49 | # This is complicated: 50 | # 51 | # SOMETIMES you need to put this file in version control. 52 | # Apple designed it poorly - if you use "custom executables", they are 53 | # saved in this file. 54 | # 99% of projects do NOT use those, so they do NOT want to version control this file. 55 | # ..but if you're in the 1%, comment out the line "*.pbxuser" 56 | 57 | *.pbxuser 58 | *.mode1v3 59 | *.mode2v3 60 | *.perspectivev3 61 | # NB: also, whitelist the default ones, some projects need to use these 62 | !default.pbxuser 63 | !default.mode1v3 64 | !default.mode2v3 65 | !default.perspectivev3 66 | 67 | 68 | #### 69 | # Xcode 4 - semi-personal settings 70 | # 71 | # 72 | # OPTION 1: --------------------------------- 73 | # throw away ALL personal settings (including custom schemes! 74 | # - unless they are "shared") 75 | # 76 | # NB: this is exclusive with OPTION 2 below 77 | xcuserdata 78 | 79 | # OPTION 2: --------------------------------- 80 | # get rid of ALL personal settings, but KEEP SOME OF THEM 81 | # - NB: you must manually uncomment the bits you want to keep 82 | # 83 | # NB: this is exclusive with OPTION 1 above 84 | # 85 | #xcuserdata/**/* 86 | 87 | # (requires option 2 above): Personal Schemes 88 | # 89 | #!xcuserdata/**/xcschemes/* 90 | 91 | #### 92 | # XCode 4 workspaces - more detailed 93 | # 94 | # Workspaces are important! They are a core feature of Xcode - don't exclude them :) 95 | # 96 | # Workspace layout is quite spammy. For reference: 97 | # 98 | # /(root)/ 99 | # /(project-name).xcodeproj/ 100 | # project.pbxproj 101 | # /project.xcworkspace/ 102 | # contents.xcworkspacedata 103 | # /xcuserdata/ 104 | # /(your name)/xcuserdatad/ 105 | # UserInterfaceState.xcuserstate 106 | # /xcsshareddata/ 107 | # /xcschemes/ 108 | # (shared scheme name).xcscheme 109 | # /xcuserdata/ 110 | # /(your name)/xcuserdatad/ 111 | # (private scheme).xcscheme 112 | # xcschememanagement.plist 113 | # 114 | # 115 | 116 | #### 117 | # Xcode 4 - Deprecated classes 118 | # 119 | # Allegedly, if you manually "deprecate" your classes, they get moved here. 120 | # 121 | # We're using source-control, so this is a "feature" that we do not want! 122 | 123 | *.moved-aside 124 | 125 | 126 | #### 127 | # UNKNOWN: recommended by others, but I can't discover what these files are 128 | # 129 | # ...none. Everything is now explained. -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | before_install: 3 | - gem install cocoapods --no-rdoc --no-ri --no-document --quiet 4 | -------------------------------------------------------------------------------- /ACReuseQueue.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'ACReuseQueue' 3 | s.version = '0.0.1' 4 | s.platform = :ios 5 | s.license = { :type => 'MIT', :file => 'LICENSE' } 6 | s.summary = 'A queue to keep and reusing objects.' 7 | s.homepage = 'https://github.com/acoomans/ACReuseQueue' 8 | s.author = { 'Arnaud Coomans' => 'arnaud.coomans@gmail.com' } 9 | s.source = { :git => 'https://github.com/acoomans/ACReuseQueue.git', :tag => '0.0.1' } 10 | s.source_files = 'ACReuseQueue/*.{h,m}' 11 | s.requires_arc = true 12 | end -------------------------------------------------------------------------------- /ACReuseQueue.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 51B020591890EFB900F6DAF5 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51B020581890EFB900F6DAF5 /* Foundation.framework */; }; 11 | 51B0205E1890EFB900F6DAF5 /* ACReuseQueue.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 51B0205D1890EFB900F6DAF5 /* ACReuseQueue.h */; }; 12 | 51B020601890EFB900F6DAF5 /* ACReuseQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 51B0205F1890EFB900F6DAF5 /* ACReuseQueue.m */; }; 13 | 51B020671890EFB900F6DAF5 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51B020661890EFB900F6DAF5 /* XCTest.framework */; }; 14 | 51B020681890EFB900F6DAF5 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51B020581890EFB900F6DAF5 /* Foundation.framework */; }; 15 | 51B0206A1890EFB900F6DAF5 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51B020691890EFB900F6DAF5 /* UIKit.framework */; }; 16 | 51B0206D1890EFB900F6DAF5 /* libACReuseQueue.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 51B020551890EFB900F6DAF5 /* libACReuseQueue.a */; }; 17 | 51B020731890EFB900F6DAF5 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 51B020711890EFB900F6DAF5 /* InfoPlist.strings */; }; 18 | 51B020751890EFB900F6DAF5 /* ACReuseQueueTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 51B020741890EFB900F6DAF5 /* ACReuseQueueTests.m */; }; 19 | 51B020831890EFD000F6DAF5 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51B020581890EFB900F6DAF5 /* Foundation.framework */; }; 20 | 51B020851890EFD000F6DAF5 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51B020841890EFD000F6DAF5 /* CoreGraphics.framework */; }; 21 | 51B020861890EFD000F6DAF5 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51B020691890EFB900F6DAF5 /* UIKit.framework */; }; 22 | 51B0208C1890EFD000F6DAF5 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 51B0208A1890EFD000F6DAF5 /* InfoPlist.strings */; }; 23 | 51B0208E1890EFD000F6DAF5 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 51B0208D1890EFD000F6DAF5 /* main.m */; }; 24 | 51B020921890EFD000F6DAF5 /* ACAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 51B020911890EFD000F6DAF5 /* ACAppDelegate.m */; }; 25 | 51B0209E1890EFD000F6DAF5 /* Main_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 51B0209C1890EFD000F6DAF5 /* Main_iPhone.storyboard */; }; 26 | 51B020A31890EFD000F6DAF5 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 51B020A21890EFD000F6DAF5 /* Images.xcassets */; }; 27 | 51B020BF1890F05200F6DAF5 /* ACButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 51B020BE1890F05200F6DAF5 /* ACButton.m */; }; 28 | 51B020C11890F07C00F6DAF5 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51B020C01890F07C00F6DAF5 /* UIKit.framework */; }; 29 | 51B020C21890F0CF00F6DAF5 /* libACReuseQueue.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 51B020551890EFB900F6DAF5 /* libACReuseQueue.a */; }; 30 | 51B322F21890FBBE0077E2A8 /* ACReusableTestObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 51B322F11890FBBE0077E2A8 /* ACReusableTestObject.m */; }; 31 | 51B322F4189109850077E2A8 /* ACReusableTest.xib in Resources */ = {isa = PBXBuildFile; fileRef = 51B322F3189109850077E2A8 /* ACReusableTest.xib */; }; 32 | 51B322FD189370560077E2A8 /* ACTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 51B322FC189370560077E2A8 /* ACTableViewController.m */; }; 33 | 51B32300189372230077E2A8 /* ACPageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 51B322FF189372230077E2A8 /* ACPageViewController.m */; }; 34 | 51B32301189380D90077E2A8 /* ACDataViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 51B020971890EFD000F6DAF5 /* ACDataViewController.m */; }; 35 | 51B32303189387F00077E2A8 /* ACButton.xib in Resources */ = {isa = PBXBuildFile; fileRef = 51B32302189387F00077E2A8 /* ACButton.xib */; }; 36 | /* End PBXBuildFile section */ 37 | 38 | /* Begin PBXContainerItemProxy section */ 39 | 51B0206B1890EFB900F6DAF5 /* PBXContainerItemProxy */ = { 40 | isa = PBXContainerItemProxy; 41 | containerPortal = 51B0204D1890EFB900F6DAF5 /* Project object */; 42 | proxyType = 1; 43 | remoteGlobalIDString = 51B020541890EFB900F6DAF5; 44 | remoteInfo = ACReuseQueue; 45 | }; 46 | /* End PBXContainerItemProxy section */ 47 | 48 | /* Begin PBXCopyFilesBuildPhase section */ 49 | 51B020531890EFB900F6DAF5 /* CopyFiles */ = { 50 | isa = PBXCopyFilesBuildPhase; 51 | buildActionMask = 2147483647; 52 | dstPath = "include/$(PRODUCT_NAME)"; 53 | dstSubfolderSpec = 16; 54 | files = ( 55 | 51B0205E1890EFB900F6DAF5 /* ACReuseQueue.h in CopyFiles */, 56 | ); 57 | runOnlyForDeploymentPostprocessing = 0; 58 | }; 59 | /* End PBXCopyFilesBuildPhase section */ 60 | 61 | /* Begin PBXFileReference section */ 62 | 51B020551890EFB900F6DAF5 /* libACReuseQueue.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libACReuseQueue.a; sourceTree = BUILT_PRODUCTS_DIR; }; 63 | 51B020581890EFB900F6DAF5 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 64 | 51B0205C1890EFB900F6DAF5 /* ACReuseQueue-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ACReuseQueue-Prefix.pch"; sourceTree = ""; }; 65 | 51B0205D1890EFB900F6DAF5 /* ACReuseQueue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ACReuseQueue.h; sourceTree = ""; }; 66 | 51B0205F1890EFB900F6DAF5 /* ACReuseQueue.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ACReuseQueue.m; sourceTree = ""; }; 67 | 51B020651890EFB900F6DAF5 /* ACReuseQueueTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ACReuseQueueTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 68 | 51B020661890EFB900F6DAF5 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 69 | 51B020691890EFB900F6DAF5 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; 70 | 51B020701890EFB900F6DAF5 /* ACReuseQueueTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ACReuseQueueTests-Info.plist"; sourceTree = ""; }; 71 | 51B020721890EFB900F6DAF5 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 72 | 51B020741890EFB900F6DAF5 /* ACReuseQueueTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ACReuseQueueTests.m; sourceTree = ""; }; 73 | 51B020821890EFD000F6DAF5 /* ACReuseQueueDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ACReuseQueueDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 74 | 51B020841890EFD000F6DAF5 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 75 | 51B020891890EFD000F6DAF5 /* ACReuseQueueDemo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ACReuseQueueDemo-Info.plist"; sourceTree = ""; }; 76 | 51B0208B1890EFD000F6DAF5 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 77 | 51B0208D1890EFD000F6DAF5 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 78 | 51B0208F1890EFD000F6DAF5 /* ACReuseQueueDemo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ACReuseQueueDemo-Prefix.pch"; sourceTree = ""; }; 79 | 51B020901890EFD000F6DAF5 /* ACAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ACAppDelegate.h; sourceTree = ""; }; 80 | 51B020911890EFD000F6DAF5 /* ACAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ACAppDelegate.m; sourceTree = ""; }; 81 | 51B020961890EFD000F6DAF5 /* ACDataViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ACDataViewController.h; sourceTree = ""; }; 82 | 51B020971890EFD000F6DAF5 /* ACDataViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ACDataViewController.m; sourceTree = ""; }; 83 | 51B0209D1890EFD000F6DAF5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main_iPhone.storyboard; sourceTree = ""; }; 84 | 51B020A21890EFD000F6DAF5 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 85 | 51B020BC1890F01700F6DAF5 /* ACReusableObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ACReusableObject.h; sourceTree = ""; }; 86 | 51B020BD1890F05200F6DAF5 /* ACButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ACButton.h; sourceTree = ""; }; 87 | 51B020BE1890F05200F6DAF5 /* ACButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ACButton.m; sourceTree = ""; }; 88 | 51B020C01890F07C00F6DAF5 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 89 | 51B322F01890FBBE0077E2A8 /* ACReusableTestObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ACReusableTestObject.h; sourceTree = ""; }; 90 | 51B322F11890FBBE0077E2A8 /* ACReusableTestObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ACReusableTestObject.m; sourceTree = ""; }; 91 | 51B322F3189109850077E2A8 /* ACReusableTest.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ACReusableTest.xib; sourceTree = ""; }; 92 | 51B322FB189370560077E2A8 /* ACTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ACTableViewController.h; sourceTree = ""; }; 93 | 51B322FC189370560077E2A8 /* ACTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ACTableViewController.m; sourceTree = ""; }; 94 | 51B322FE189372230077E2A8 /* ACPageViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ACPageViewController.h; sourceTree = ""; }; 95 | 51B322FF189372230077E2A8 /* ACPageViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ACPageViewController.m; sourceTree = ""; }; 96 | 51B32302189387F00077E2A8 /* ACButton.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ACButton.xib; sourceTree = ""; }; 97 | 51B3230418938B9C0077E2A8 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = text; path = README.md; sourceTree = ""; }; 98 | /* End PBXFileReference section */ 99 | 100 | /* Begin PBXFrameworksBuildPhase section */ 101 | 51B020521890EFB900F6DAF5 /* Frameworks */ = { 102 | isa = PBXFrameworksBuildPhase; 103 | buildActionMask = 2147483647; 104 | files = ( 105 | 51B020C11890F07C00F6DAF5 /* UIKit.framework in Frameworks */, 106 | 51B020591890EFB900F6DAF5 /* Foundation.framework in Frameworks */, 107 | ); 108 | runOnlyForDeploymentPostprocessing = 0; 109 | }; 110 | 51B020621890EFB900F6DAF5 /* Frameworks */ = { 111 | isa = PBXFrameworksBuildPhase; 112 | buildActionMask = 2147483647; 113 | files = ( 114 | 51B0206D1890EFB900F6DAF5 /* libACReuseQueue.a in Frameworks */, 115 | 51B020671890EFB900F6DAF5 /* XCTest.framework in Frameworks */, 116 | 51B0206A1890EFB900F6DAF5 /* UIKit.framework in Frameworks */, 117 | 51B020681890EFB900F6DAF5 /* Foundation.framework in Frameworks */, 118 | ); 119 | runOnlyForDeploymentPostprocessing = 0; 120 | }; 121 | 51B0207F1890EFD000F6DAF5 /* Frameworks */ = { 122 | isa = PBXFrameworksBuildPhase; 123 | buildActionMask = 2147483647; 124 | files = ( 125 | 51B020C21890F0CF00F6DAF5 /* libACReuseQueue.a in Frameworks */, 126 | 51B020851890EFD000F6DAF5 /* CoreGraphics.framework in Frameworks */, 127 | 51B020861890EFD000F6DAF5 /* UIKit.framework in Frameworks */, 128 | 51B020831890EFD000F6DAF5 /* Foundation.framework in Frameworks */, 129 | ); 130 | runOnlyForDeploymentPostprocessing = 0; 131 | }; 132 | /* End PBXFrameworksBuildPhase section */ 133 | 134 | /* Begin PBXGroup section */ 135 | 51B0204C1890EFB900F6DAF5 = { 136 | isa = PBXGroup; 137 | children = ( 138 | 51B3230418938B9C0077E2A8 /* README.md */, 139 | 51B0205A1890EFB900F6DAF5 /* ACReuseQueue */, 140 | 51B0206E1890EFB900F6DAF5 /* ACReuseQueueTests */, 141 | 51B020871890EFD000F6DAF5 /* ACReuseQueueDemo */, 142 | 51B020571890EFB900F6DAF5 /* Frameworks */, 143 | 51B020561890EFB900F6DAF5 /* Products */, 144 | ); 145 | sourceTree = ""; 146 | }; 147 | 51B020561890EFB900F6DAF5 /* Products */ = { 148 | isa = PBXGroup; 149 | children = ( 150 | 51B020551890EFB900F6DAF5 /* libACReuseQueue.a */, 151 | 51B020651890EFB900F6DAF5 /* ACReuseQueueTests.xctest */, 152 | 51B020821890EFD000F6DAF5 /* ACReuseQueueDemo.app */, 153 | ); 154 | name = Products; 155 | sourceTree = ""; 156 | }; 157 | 51B020571890EFB900F6DAF5 /* Frameworks */ = { 158 | isa = PBXGroup; 159 | children = ( 160 | 51B020C01890F07C00F6DAF5 /* UIKit.framework */, 161 | 51B020581890EFB900F6DAF5 /* Foundation.framework */, 162 | 51B020661890EFB900F6DAF5 /* XCTest.framework */, 163 | 51B020691890EFB900F6DAF5 /* UIKit.framework */, 164 | 51B020841890EFD000F6DAF5 /* CoreGraphics.framework */, 165 | ); 166 | name = Frameworks; 167 | sourceTree = ""; 168 | }; 169 | 51B0205A1890EFB900F6DAF5 /* ACReuseQueue */ = { 170 | isa = PBXGroup; 171 | children = ( 172 | 51B020BC1890F01700F6DAF5 /* ACReusableObject.h */, 173 | 51B0205D1890EFB900F6DAF5 /* ACReuseQueue.h */, 174 | 51B0205F1890EFB900F6DAF5 /* ACReuseQueue.m */, 175 | 51B0205B1890EFB900F6DAF5 /* Supporting Files */, 176 | ); 177 | path = ACReuseQueue; 178 | sourceTree = ""; 179 | }; 180 | 51B0205B1890EFB900F6DAF5 /* Supporting Files */ = { 181 | isa = PBXGroup; 182 | children = ( 183 | 51B0205C1890EFB900F6DAF5 /* ACReuseQueue-Prefix.pch */, 184 | ); 185 | name = "Supporting Files"; 186 | sourceTree = ""; 187 | }; 188 | 51B0206E1890EFB900F6DAF5 /* ACReuseQueueTests */ = { 189 | isa = PBXGroup; 190 | children = ( 191 | 51B020741890EFB900F6DAF5 /* ACReuseQueueTests.m */, 192 | 51B322F01890FBBE0077E2A8 /* ACReusableTestObject.h */, 193 | 51B322F11890FBBE0077E2A8 /* ACReusableTestObject.m */, 194 | 51B322F3189109850077E2A8 /* ACReusableTest.xib */, 195 | 51B0206F1890EFB900F6DAF5 /* Supporting Files */, 196 | ); 197 | path = ACReuseQueueTests; 198 | sourceTree = ""; 199 | }; 200 | 51B0206F1890EFB900F6DAF5 /* Supporting Files */ = { 201 | isa = PBXGroup; 202 | children = ( 203 | 51B020701890EFB900F6DAF5 /* ACReuseQueueTests-Info.plist */, 204 | 51B020711890EFB900F6DAF5 /* InfoPlist.strings */, 205 | ); 206 | name = "Supporting Files"; 207 | sourceTree = ""; 208 | }; 209 | 51B020871890EFD000F6DAF5 /* ACReuseQueueDemo */ = { 210 | isa = PBXGroup; 211 | children = ( 212 | 51B020901890EFD000F6DAF5 /* ACAppDelegate.h */, 213 | 51B020911890EFD000F6DAF5 /* ACAppDelegate.m */, 214 | 51B322FB189370560077E2A8 /* ACTableViewController.h */, 215 | 51B322FC189370560077E2A8 /* ACTableViewController.m */, 216 | 51B322FE189372230077E2A8 /* ACPageViewController.h */, 217 | 51B322FF189372230077E2A8 /* ACPageViewController.m */, 218 | 51B020961890EFD000F6DAF5 /* ACDataViewController.h */, 219 | 51B020971890EFD000F6DAF5 /* ACDataViewController.m */, 220 | 51B020BD1890F05200F6DAF5 /* ACButton.h */, 221 | 51B020BE1890F05200F6DAF5 /* ACButton.m */, 222 | 51B32302189387F00077E2A8 /* ACButton.xib */, 223 | 51B0209C1890EFD000F6DAF5 /* Main_iPhone.storyboard */, 224 | 51B020A21890EFD000F6DAF5 /* Images.xcassets */, 225 | 51B020881890EFD000F6DAF5 /* Supporting Files */, 226 | ); 227 | path = ACReuseQueueDemo; 228 | sourceTree = ""; 229 | }; 230 | 51B020881890EFD000F6DAF5 /* Supporting Files */ = { 231 | isa = PBXGroup; 232 | children = ( 233 | 51B020891890EFD000F6DAF5 /* ACReuseQueueDemo-Info.plist */, 234 | 51B0208A1890EFD000F6DAF5 /* InfoPlist.strings */, 235 | 51B0208D1890EFD000F6DAF5 /* main.m */, 236 | 51B0208F1890EFD000F6DAF5 /* ACReuseQueueDemo-Prefix.pch */, 237 | ); 238 | name = "Supporting Files"; 239 | sourceTree = ""; 240 | }; 241 | /* End PBXGroup section */ 242 | 243 | /* Begin PBXLegacyTarget section */ 244 | 51B020C31890F10F00F6DAF5 /* Documentation */ = { 245 | isa = PBXLegacyTarget; 246 | buildArgumentsString = "--project-name \"ACReuseQueue\"\n--project-company \"Arnaud Coomans\"\n--company-id \"com.acoomans\"\n--output build\n--create-docset \n--install-docset \n--create-html \n--exit-threshold 2 \n--no-repeat-first-par \n."; 247 | buildConfigurationList = 51B020C41890F10F00F6DAF5 /* Build configuration list for PBXLegacyTarget "Documentation" */; 248 | buildPhases = ( 249 | ); 250 | buildToolPath = /usr/local/bin/appledoc; 251 | buildWorkingDirectory = ACReuseQueue; 252 | dependencies = ( 253 | ); 254 | name = Documentation; 255 | passBuildSettingsInEnvironment = 1; 256 | productName = Documentation; 257 | }; 258 | /* End PBXLegacyTarget section */ 259 | 260 | /* Begin PBXNativeTarget section */ 261 | 51B020541890EFB900F6DAF5 /* ACReuseQueue */ = { 262 | isa = PBXNativeTarget; 263 | buildConfigurationList = 51B020781890EFB900F6DAF5 /* Build configuration list for PBXNativeTarget "ACReuseQueue" */; 264 | buildPhases = ( 265 | 51B020511890EFB900F6DAF5 /* Sources */, 266 | 51B020521890EFB900F6DAF5 /* Frameworks */, 267 | 51B020531890EFB900F6DAF5 /* CopyFiles */, 268 | ); 269 | buildRules = ( 270 | ); 271 | dependencies = ( 272 | ); 273 | name = ACReuseQueue; 274 | productName = ACReuseQueue; 275 | productReference = 51B020551890EFB900F6DAF5 /* libACReuseQueue.a */; 276 | productType = "com.apple.product-type.library.static"; 277 | }; 278 | 51B020641890EFB900F6DAF5 /* ACReuseQueueTests */ = { 279 | isa = PBXNativeTarget; 280 | buildConfigurationList = 51B0207B1890EFB900F6DAF5 /* Build configuration list for PBXNativeTarget "ACReuseQueueTests" */; 281 | buildPhases = ( 282 | 51B020611890EFB900F6DAF5 /* Sources */, 283 | 51B020621890EFB900F6DAF5 /* Frameworks */, 284 | 51B020631890EFB900F6DAF5 /* Resources */, 285 | ); 286 | buildRules = ( 287 | ); 288 | dependencies = ( 289 | 51B0206C1890EFB900F6DAF5 /* PBXTargetDependency */, 290 | ); 291 | name = ACReuseQueueTests; 292 | productName = ACReuseQueueTests; 293 | productReference = 51B020651890EFB900F6DAF5 /* ACReuseQueueTests.xctest */; 294 | productType = "com.apple.product-type.bundle.unit-test"; 295 | }; 296 | 51B020811890EFD000F6DAF5 /* ACReuseQueueDemo */ = { 297 | isa = PBXNativeTarget; 298 | buildConfigurationList = 51B020B61890EFD000F6DAF5 /* Build configuration list for PBXNativeTarget "ACReuseQueueDemo" */; 299 | buildPhases = ( 300 | 51B0207E1890EFD000F6DAF5 /* Sources */, 301 | 51B0207F1890EFD000F6DAF5 /* Frameworks */, 302 | 51B020801890EFD000F6DAF5 /* Resources */, 303 | ); 304 | buildRules = ( 305 | ); 306 | dependencies = ( 307 | ); 308 | name = ACReuseQueueDemo; 309 | productName = ACReuseQueueDemo; 310 | productReference = 51B020821890EFD000F6DAF5 /* ACReuseQueueDemo.app */; 311 | productType = "com.apple.product-type.application"; 312 | }; 313 | /* End PBXNativeTarget section */ 314 | 315 | /* Begin PBXProject section */ 316 | 51B0204D1890EFB900F6DAF5 /* Project object */ = { 317 | isa = PBXProject; 318 | attributes = { 319 | LastUpgradeCheck = 0500; 320 | ORGANIZATIONNAME = "Arnaud Coomans"; 321 | TargetAttributes = { 322 | 51B020641890EFB900F6DAF5 = { 323 | TestTargetID = 51B020541890EFB900F6DAF5; 324 | }; 325 | 51B020811890EFD000F6DAF5 = { 326 | DevelopmentTeam = YVT7JGDS4H; 327 | }; 328 | }; 329 | }; 330 | buildConfigurationList = 51B020501890EFB900F6DAF5 /* Build configuration list for PBXProject "ACReuseQueue" */; 331 | compatibilityVersion = "Xcode 3.2"; 332 | developmentRegion = English; 333 | hasScannedForEncodings = 0; 334 | knownRegions = ( 335 | en, 336 | Base, 337 | ); 338 | mainGroup = 51B0204C1890EFB900F6DAF5; 339 | productRefGroup = 51B020561890EFB900F6DAF5 /* Products */; 340 | projectDirPath = ""; 341 | projectRoot = ""; 342 | targets = ( 343 | 51B020541890EFB900F6DAF5 /* ACReuseQueue */, 344 | 51B020641890EFB900F6DAF5 /* ACReuseQueueTests */, 345 | 51B020811890EFD000F6DAF5 /* ACReuseQueueDemo */, 346 | 51B020C31890F10F00F6DAF5 /* Documentation */, 347 | ); 348 | }; 349 | /* End PBXProject section */ 350 | 351 | /* Begin PBXResourcesBuildPhase section */ 352 | 51B020631890EFB900F6DAF5 /* Resources */ = { 353 | isa = PBXResourcesBuildPhase; 354 | buildActionMask = 2147483647; 355 | files = ( 356 | 51B322F4189109850077E2A8 /* ACReusableTest.xib in Resources */, 357 | 51B020731890EFB900F6DAF5 /* InfoPlist.strings in Resources */, 358 | ); 359 | runOnlyForDeploymentPostprocessing = 0; 360 | }; 361 | 51B020801890EFD000F6DAF5 /* Resources */ = { 362 | isa = PBXResourcesBuildPhase; 363 | buildActionMask = 2147483647; 364 | files = ( 365 | 51B020A31890EFD000F6DAF5 /* Images.xcassets in Resources */, 366 | 51B32303189387F00077E2A8 /* ACButton.xib in Resources */, 367 | 51B0209E1890EFD000F6DAF5 /* Main_iPhone.storyboard in Resources */, 368 | 51B0208C1890EFD000F6DAF5 /* InfoPlist.strings in Resources */, 369 | ); 370 | runOnlyForDeploymentPostprocessing = 0; 371 | }; 372 | /* End PBXResourcesBuildPhase section */ 373 | 374 | /* Begin PBXSourcesBuildPhase section */ 375 | 51B020511890EFB900F6DAF5 /* Sources */ = { 376 | isa = PBXSourcesBuildPhase; 377 | buildActionMask = 2147483647; 378 | files = ( 379 | 51B020601890EFB900F6DAF5 /* ACReuseQueue.m in Sources */, 380 | ); 381 | runOnlyForDeploymentPostprocessing = 0; 382 | }; 383 | 51B020611890EFB900F6DAF5 /* Sources */ = { 384 | isa = PBXSourcesBuildPhase; 385 | buildActionMask = 2147483647; 386 | files = ( 387 | 51B020751890EFB900F6DAF5 /* ACReuseQueueTests.m in Sources */, 388 | 51B322F21890FBBE0077E2A8 /* ACReusableTestObject.m in Sources */, 389 | ); 390 | runOnlyForDeploymentPostprocessing = 0; 391 | }; 392 | 51B0207E1890EFD000F6DAF5 /* Sources */ = { 393 | isa = PBXSourcesBuildPhase; 394 | buildActionMask = 2147483647; 395 | files = ( 396 | 51B020921890EFD000F6DAF5 /* ACAppDelegate.m in Sources */, 397 | 51B32300189372230077E2A8 /* ACPageViewController.m in Sources */, 398 | 51B0208E1890EFD000F6DAF5 /* main.m in Sources */, 399 | 51B322FD189370560077E2A8 /* ACTableViewController.m in Sources */, 400 | 51B020BF1890F05200F6DAF5 /* ACButton.m in Sources */, 401 | 51B32301189380D90077E2A8 /* ACDataViewController.m in Sources */, 402 | ); 403 | runOnlyForDeploymentPostprocessing = 0; 404 | }; 405 | /* End PBXSourcesBuildPhase section */ 406 | 407 | /* Begin PBXTargetDependency section */ 408 | 51B0206C1890EFB900F6DAF5 /* PBXTargetDependency */ = { 409 | isa = PBXTargetDependency; 410 | target = 51B020541890EFB900F6DAF5 /* ACReuseQueue */; 411 | targetProxy = 51B0206B1890EFB900F6DAF5 /* PBXContainerItemProxy */; 412 | }; 413 | /* End PBXTargetDependency section */ 414 | 415 | /* Begin PBXVariantGroup section */ 416 | 51B020711890EFB900F6DAF5 /* InfoPlist.strings */ = { 417 | isa = PBXVariantGroup; 418 | children = ( 419 | 51B020721890EFB900F6DAF5 /* en */, 420 | ); 421 | name = InfoPlist.strings; 422 | sourceTree = ""; 423 | }; 424 | 51B0208A1890EFD000F6DAF5 /* InfoPlist.strings */ = { 425 | isa = PBXVariantGroup; 426 | children = ( 427 | 51B0208B1890EFD000F6DAF5 /* en */, 428 | ); 429 | name = InfoPlist.strings; 430 | sourceTree = ""; 431 | }; 432 | 51B0209C1890EFD000F6DAF5 /* Main_iPhone.storyboard */ = { 433 | isa = PBXVariantGroup; 434 | children = ( 435 | 51B0209D1890EFD000F6DAF5 /* Base */, 436 | ); 437 | name = Main_iPhone.storyboard; 438 | sourceTree = ""; 439 | }; 440 | /* End PBXVariantGroup section */ 441 | 442 | /* Begin XCBuildConfiguration section */ 443 | 51B020761890EFB900F6DAF5 /* Debug */ = { 444 | isa = XCBuildConfiguration; 445 | buildSettings = { 446 | ALWAYS_SEARCH_USER_PATHS = NO; 447 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 448 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 449 | CLANG_CXX_LIBRARY = "libc++"; 450 | CLANG_ENABLE_MODULES = YES; 451 | CLANG_ENABLE_OBJC_ARC = YES; 452 | CLANG_WARN_BOOL_CONVERSION = YES; 453 | CLANG_WARN_CONSTANT_CONVERSION = YES; 454 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 455 | CLANG_WARN_EMPTY_BODY = YES; 456 | CLANG_WARN_ENUM_CONVERSION = YES; 457 | CLANG_WARN_INT_CONVERSION = YES; 458 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 459 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 460 | COPY_PHASE_STRIP = NO; 461 | GCC_C_LANGUAGE_STANDARD = gnu99; 462 | GCC_DYNAMIC_NO_PIC = NO; 463 | GCC_OPTIMIZATION_LEVEL = 0; 464 | GCC_PREPROCESSOR_DEFINITIONS = ( 465 | "DEBUG=1", 466 | "$(inherited)", 467 | ); 468 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 469 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 470 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 471 | GCC_WARN_UNDECLARED_SELECTOR = YES; 472 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 473 | GCC_WARN_UNUSED_FUNCTION = YES; 474 | GCC_WARN_UNUSED_VARIABLE = YES; 475 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 476 | ONLY_ACTIVE_ARCH = YES; 477 | SDKROOT = iphoneos; 478 | }; 479 | name = Debug; 480 | }; 481 | 51B020771890EFB900F6DAF5 /* Release */ = { 482 | isa = XCBuildConfiguration; 483 | buildSettings = { 484 | ALWAYS_SEARCH_USER_PATHS = NO; 485 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 486 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 487 | CLANG_CXX_LIBRARY = "libc++"; 488 | CLANG_ENABLE_MODULES = YES; 489 | CLANG_ENABLE_OBJC_ARC = YES; 490 | CLANG_WARN_BOOL_CONVERSION = YES; 491 | CLANG_WARN_CONSTANT_CONVERSION = YES; 492 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 493 | CLANG_WARN_EMPTY_BODY = YES; 494 | CLANG_WARN_ENUM_CONVERSION = YES; 495 | CLANG_WARN_INT_CONVERSION = YES; 496 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 497 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 498 | COPY_PHASE_STRIP = YES; 499 | ENABLE_NS_ASSERTIONS = NO; 500 | GCC_C_LANGUAGE_STANDARD = gnu99; 501 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 502 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 503 | GCC_WARN_UNDECLARED_SELECTOR = YES; 504 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 505 | GCC_WARN_UNUSED_FUNCTION = YES; 506 | GCC_WARN_UNUSED_VARIABLE = YES; 507 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 508 | SDKROOT = iphoneos; 509 | VALIDATE_PRODUCT = YES; 510 | }; 511 | name = Release; 512 | }; 513 | 51B020791890EFB900F6DAF5 /* Debug */ = { 514 | isa = XCBuildConfiguration; 515 | buildSettings = { 516 | DSTROOT = /tmp/ACReuseQueue.dst; 517 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 518 | GCC_PREFIX_HEADER = "ACReuseQueue/ACReuseQueue-Prefix.pch"; 519 | OTHER_LDFLAGS = "-ObjC"; 520 | PRODUCT_NAME = "$(TARGET_NAME)"; 521 | SKIP_INSTALL = YES; 522 | }; 523 | name = Debug; 524 | }; 525 | 51B0207A1890EFB900F6DAF5 /* Release */ = { 526 | isa = XCBuildConfiguration; 527 | buildSettings = { 528 | DSTROOT = /tmp/ACReuseQueue.dst; 529 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 530 | GCC_PREFIX_HEADER = "ACReuseQueue/ACReuseQueue-Prefix.pch"; 531 | OTHER_LDFLAGS = "-ObjC"; 532 | PRODUCT_NAME = "$(TARGET_NAME)"; 533 | SKIP_INSTALL = YES; 534 | }; 535 | name = Release; 536 | }; 537 | 51B0207C1890EFB900F6DAF5 /* Debug */ = { 538 | isa = XCBuildConfiguration; 539 | buildSettings = { 540 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 541 | FRAMEWORK_SEARCH_PATHS = ( 542 | "$(SDKROOT)/Developer/Library/Frameworks", 543 | "$(inherited)", 544 | "$(DEVELOPER_FRAMEWORKS_DIR)", 545 | ); 546 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 547 | GCC_PREFIX_HEADER = "ACReuseQueue/ACReuseQueue-Prefix.pch"; 548 | GCC_PREPROCESSOR_DEFINITIONS = ( 549 | "DEBUG=1", 550 | "$(inherited)", 551 | ); 552 | INFOPLIST_FILE = "ACReuseQueueTests/ACReuseQueueTests-Info.plist"; 553 | PRODUCT_NAME = "$(TARGET_NAME)"; 554 | WRAPPER_EXTENSION = xctest; 555 | }; 556 | name = Debug; 557 | }; 558 | 51B0207D1890EFB900F6DAF5 /* Release */ = { 559 | isa = XCBuildConfiguration; 560 | buildSettings = { 561 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 562 | FRAMEWORK_SEARCH_PATHS = ( 563 | "$(SDKROOT)/Developer/Library/Frameworks", 564 | "$(inherited)", 565 | "$(DEVELOPER_FRAMEWORKS_DIR)", 566 | ); 567 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 568 | GCC_PREFIX_HEADER = "ACReuseQueue/ACReuseQueue-Prefix.pch"; 569 | INFOPLIST_FILE = "ACReuseQueueTests/ACReuseQueueTests-Info.plist"; 570 | PRODUCT_NAME = "$(TARGET_NAME)"; 571 | WRAPPER_EXTENSION = xctest; 572 | }; 573 | name = Release; 574 | }; 575 | 51B020B71890EFD000F6DAF5 /* Debug */ = { 576 | isa = XCBuildConfiguration; 577 | buildSettings = { 578 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 579 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 580 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 581 | CODE_SIGN_IDENTITY = "iPhone Developer"; 582 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 583 | FRAMEWORK_SEARCH_PATHS = ( 584 | "$(inherited)", 585 | "$(DEVELOPER_FRAMEWORKS_DIR)", 586 | ); 587 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 588 | GCC_PREFIX_HEADER = "ACReuseQueueDemo/ACReuseQueueDemo-Prefix.pch"; 589 | GCC_PREPROCESSOR_DEFINITIONS = ( 590 | "DEBUG=1", 591 | "$(inherited)", 592 | ); 593 | INFOPLIST_FILE = "ACReuseQueueDemo/ACReuseQueueDemo-Info.plist"; 594 | PRODUCT_NAME = "$(TARGET_NAME)"; 595 | TARGETED_DEVICE_FAMILY = 1; 596 | WRAPPER_EXTENSION = app; 597 | }; 598 | name = Debug; 599 | }; 600 | 51B020B81890EFD000F6DAF5 /* Release */ = { 601 | isa = XCBuildConfiguration; 602 | buildSettings = { 603 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 604 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 605 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 606 | CODE_SIGN_IDENTITY = "iPhone Developer"; 607 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 608 | FRAMEWORK_SEARCH_PATHS = ( 609 | "$(inherited)", 610 | "$(DEVELOPER_FRAMEWORKS_DIR)", 611 | ); 612 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 613 | GCC_PREFIX_HEADER = "ACReuseQueueDemo/ACReuseQueueDemo-Prefix.pch"; 614 | INFOPLIST_FILE = "ACReuseQueueDemo/ACReuseQueueDemo-Info.plist"; 615 | PRODUCT_NAME = "$(TARGET_NAME)"; 616 | TARGETED_DEVICE_FAMILY = 1; 617 | WRAPPER_EXTENSION = app; 618 | }; 619 | name = Release; 620 | }; 621 | 51B020C51890F10F00F6DAF5 /* Debug */ = { 622 | isa = XCBuildConfiguration; 623 | buildSettings = { 624 | DEBUGGING_SYMBOLS = YES; 625 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 626 | GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 627 | GCC_OPTIMIZATION_LEVEL = 0; 628 | GCC_PREPROCESSOR_DEFINITIONS = ( 629 | "DEBUG=1", 630 | "$(inherited)", 631 | ); 632 | MACOSX_DEPLOYMENT_TARGET = 10.9; 633 | OTHER_CFLAGS = ""; 634 | OTHER_LDFLAGS = ""; 635 | PRODUCT_NAME = "$(TARGET_NAME)"; 636 | SDKROOT = macosx; 637 | }; 638 | name = Debug; 639 | }; 640 | 51B020C61890F10F00F6DAF5 /* Release */ = { 641 | isa = XCBuildConfiguration; 642 | buildSettings = { 643 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 644 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 645 | MACOSX_DEPLOYMENT_TARGET = 10.9; 646 | OTHER_CFLAGS = ""; 647 | OTHER_LDFLAGS = ""; 648 | PRODUCT_NAME = "$(TARGET_NAME)"; 649 | SDKROOT = macosx; 650 | }; 651 | name = Release; 652 | }; 653 | /* End XCBuildConfiguration section */ 654 | 655 | /* Begin XCConfigurationList section */ 656 | 51B020501890EFB900F6DAF5 /* Build configuration list for PBXProject "ACReuseQueue" */ = { 657 | isa = XCConfigurationList; 658 | buildConfigurations = ( 659 | 51B020761890EFB900F6DAF5 /* Debug */, 660 | 51B020771890EFB900F6DAF5 /* Release */, 661 | ); 662 | defaultConfigurationIsVisible = 0; 663 | defaultConfigurationName = Release; 664 | }; 665 | 51B020781890EFB900F6DAF5 /* Build configuration list for PBXNativeTarget "ACReuseQueue" */ = { 666 | isa = XCConfigurationList; 667 | buildConfigurations = ( 668 | 51B020791890EFB900F6DAF5 /* Debug */, 669 | 51B0207A1890EFB900F6DAF5 /* Release */, 670 | ); 671 | defaultConfigurationIsVisible = 0; 672 | defaultConfigurationName = Release; 673 | }; 674 | 51B0207B1890EFB900F6DAF5 /* Build configuration list for PBXNativeTarget "ACReuseQueueTests" */ = { 675 | isa = XCConfigurationList; 676 | buildConfigurations = ( 677 | 51B0207C1890EFB900F6DAF5 /* Debug */, 678 | 51B0207D1890EFB900F6DAF5 /* Release */, 679 | ); 680 | defaultConfigurationIsVisible = 0; 681 | defaultConfigurationName = Release; 682 | }; 683 | 51B020B61890EFD000F6DAF5 /* Build configuration list for PBXNativeTarget "ACReuseQueueDemo" */ = { 684 | isa = XCConfigurationList; 685 | buildConfigurations = ( 686 | 51B020B71890EFD000F6DAF5 /* Debug */, 687 | 51B020B81890EFD000F6DAF5 /* Release */, 688 | ); 689 | defaultConfigurationIsVisible = 0; 690 | defaultConfigurationName = Release; 691 | }; 692 | 51B020C41890F10F00F6DAF5 /* Build configuration list for PBXLegacyTarget "Documentation" */ = { 693 | isa = XCConfigurationList; 694 | buildConfigurations = ( 695 | 51B020C51890F10F00F6DAF5 /* Debug */, 696 | 51B020C61890F10F00F6DAF5 /* Release */, 697 | ); 698 | defaultConfigurationIsVisible = 0; 699 | defaultConfigurationName = Release; 700 | }; 701 | /* End XCConfigurationList section */ 702 | }; 703 | rootObject = 51B0204D1890EFB900F6DAF5 /* Project object */; 704 | } 705 | -------------------------------------------------------------------------------- /ACReuseQueue.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ACReuseQueue/ACReusableObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // ACReusableObject.h 3 | // ACReuseQueueDemo 4 | // 5 | // Created by Arnaud Coomans on 16/01/14. 6 | // Copyright (c) 2014 Arnaud Coomans. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | /** The ACReusableObject protocol describes the methods and properties to be implemented for an object to be reused by a ACReuseQueue. 13 | * 14 | * A reusable object must have a reuse identifier to be reused. 15 | */ 16 | 17 | @protocol ACReusableObject 18 | @optional 19 | 20 | /** Initializes and returns an object with a reuse identifier. 21 | * @param identifier A string used to identify the object if it is to be reused. Pass nil if the object is not to be reused. 22 | */ 23 | - (instancetype)initWithReuseIdentifier:(NSString*)identifier; 24 | 25 | /** A string used to identify an object that is reusable. 26 | * @discussion The reuse identifier is associated with an object with the intent to reuse it (for performance reasons). It can be assigned to the object in initWithReuseIdentifier:, if the method is implemented, or with the accessor. A reusable object is usually not supposed to change its identifier once one has been set. A ACReuseQueue object maintains a queue (or list) of the currently reusable objects, each with its own reuse identifier, and makes them available in the dequeueReusableObjectWithIdentifier: method. 27 | */ 28 | @property (nonatomic, copy) NSString *reuseIdentifier; 29 | 30 | /** Prepares a reusable object for reuse by a ACReuseQueue. 31 | * @discussion If an object is reusable -- that is, it has a reuse identifier -- this method is invoked just before the object is returned from the ACReuseQueue method dequeueReusableObjectWithIdentifier:. For performance reasons, you should only reset attributes of the object that needs to be. If the object does not have an associated reuse identifier, this method is not called. If you override this method, you must be sure to invoke the superclass implementation. 32 | */ 33 | - (void)prepareForReuse; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /ACReuseQueue/ACReuseQueue-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #ifdef __OBJC__ 8 | #import 9 | #endif 10 | -------------------------------------------------------------------------------- /ACReuseQueue/ACReuseQueue.h: -------------------------------------------------------------------------------- 1 | // 2 | // ACReuseQueue.h 3 | // ACReuseQueueDemo 4 | // 5 | // Created by Arnaud Coomans on 16/01/14. 6 | // Copyright (c) 2014 Arnaud Coomans. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "ACReusableObject.h" 12 | 13 | 14 | extern NSString * const ACReuseQueueEmptyException; 15 | 16 | /** An instance of ACReusableQueue is a means for keeping and reusing objects. 17 | * 18 | * A reuse queue object maintains a queue (or list) of the currently reusable objects, each with its own reuse identifier. It makes unused objects available in the dequeueReusableObjectWithIdentifier: method. If no object is available, and a class or a Nib has previously been registered with registerNib:forObjectReuseIdentifier: or registerClass:forObjectReuseIdentifier:, a new object will be created and returned instead. When an object is not used anymore, enqueueReusableObject: should be called to return the reusable object to the queue and mark it as unused. 19 | * 20 | * A reuse queue is a way to quickly reuse objects when object allocation and initialization is time-consuming. This reuse queue is inspired after UITableView's for reusing cells, headers and footers. 21 | * 22 | */ 23 | 24 | 25 | @interface ACReuseQueue : NSObject 26 | 27 | 28 | /** @name Getting the default queue */ 29 | 30 | /** Return the default reuse queue 31 | * @discussion The current process’s default reuse queue. 32 | */ 33 | + (instancetype)defaultQueue; 34 | 35 | 36 | /** @name Properties */ 37 | 38 | /** Maximum number of unused object in the queue 39 | */ 40 | @property (nonatomic, assign) NSUInteger maxUnusedCount; 41 | 42 | 43 | /** @name Enqueueing and dequeuing objects */ 44 | 45 | /** Returns a reusable object located by its identifier. 46 | * @param reusableObject A ACReusableObject not in use anymore and to be queued for further reuse. 47 | * @discussion For performance reasons, it may be necessary to reuse existing objects. Call this method to put a reusable object back in the queue for further reuse. Avoid manipulating the object after calling this method as it might be dequeued and reused somewhere else. 48 | */ 49 | - (void)enqueueReusableObject:(id)reusableObject; 50 | 51 | /** Returns a reusable object located by its identifier. 52 | * @param identifier A string identifying the object to be reused. This parameter must not be nil. 53 | * @return A reusable object with the associated identifier or nil if no such object exists in the ACReusableQueue. 54 | * @discussion For performance reasons, it may be necessary to reuse existing objects. A ACReuseQueue maintains a list of reusable objects marked for reuse. This method dequeues an existing object if one is available or creates a new one using the class or nib file you previously registered. If no object is available for reuse and you did not register a class or nib file, this method returns nil. If you registered a class for the specified identifier and a new object must be created, this method initializes the object by calling its initWithReuseIdentifier: method. For nib-based objects, this method loads the object from the provided nib file. If an existing object was available for reuse, this method calls the object's prepareForReuse method instead. 55 | */ 56 | - (id)dequeueReusableObjectWithIdentifier:(NSString *)identifier __attribute((nonnull(1))); 57 | 58 | /** @name Registering classes or nibs */ 59 | 60 | /** Registers a nib object containing a reusable object with a specified identifier. 61 | * @param nib A nib object that specifies the nib file to use to create the object. This parameter cannot be nil. 62 | * @param identifier The reuse identifier for the object. This parameter must not be nil and must not be an empty string. 63 | * @discussion Prior to dequeueing any object, call this method or the registerClass:forObjectReuseIdentifier: method to tell the queue how to create new objects. If an object of the specified type is not currently in a reuse queue, it uses the provided information to create a new object automatically. If you previously registered a class or nib file with the same reuse identifier, the nib you specify in the nib parameter replaces the old entry. You may specify nil for nib if you want to unregister the nib from the specified reuse identifier. 64 | */ 65 | - (void)registerNib:(UINib *)nib forObjectReuseIdentifier:(NSString *)identifier __attribute((nonnull(1,2))); 66 | 67 | /** Registers by its name a nib object containing a reusable object with a specified identifier. 68 | * @param nibName The name of the nib file to use to create the object. The nib file name should not contain any leading path information. This parameter cannot be nil. 69 | * @param nibBundle The bundle in which to search for the nib file. 70 | * @param identifier The reuse identifier for the object. This parameter must not be nil and must not be an empty string. 71 | * @discussion This method is a convenience method. See registerNib:forObjectReuseIdentifier: for details. 72 | */ 73 | - (void)registerNibWithName:(NSString *)nibName bundle:(NSBundle *)nibBundle forObjectReuseIdentifier:(NSString *)identifier __attribute((nonnull(1,3))); 74 | 75 | /** Registers a class for use in creating new objects. 76 | * @param objectClass The class of an object that you want to use. 77 | * @param identifier The reuse identifier for the object. This parameter must not be nil and must not be an empty string. 78 | * @discussion Prior to dequeueing any object, call this method or the registerNib:forObjectReuseIdentifier: method to tell the queue how to create new objects. If an object of the specified type is not currently in a reuse queue, it uses the provided information to create a new object automatically. If you previously registered a class or nib file with the same reuse identifier, the class you specify in the objectClass parameter replaces the old entry. You may specify nil for objectClass if you want to unregister the class from the specified reuse identifier. 79 | */ 80 | - (void)registerClass:(Class)objectClass forObjectReuseIdentifier:(NSString *)identifier __attribute((nonnull(2))); 81 | 82 | 83 | @property (nonatomic, assign, readonly) NSUInteger unusedCount; 84 | @property (nonatomic, assign, readonly) NSUInteger usedCount; 85 | @property (nonatomic, assign, readonly) NSUInteger count; 86 | 87 | - (void)removeAllUnusedObjects; 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /ACReuseQueue/ACReuseQueue.m: -------------------------------------------------------------------------------- 1 | // 2 | // ACReuseQueue.m 3 | // ACReuseQueueDemo 4 | // 5 | // Created by Arnaud Coomans on 16/01/14. 6 | // Copyright (c) 2014 Arnaud Coomans. All rights reserved. 7 | // 8 | 9 | #import "ACReuseQueue.h" 10 | 11 | NSString * const ACReuseQueueEmptyException = @"ACReuseQueueEmptyException"; 12 | 13 | 14 | @interface ACReuseQueue () 15 | @property (nonatomic, strong) NSMutableDictionary *dictionaryOfSetsOfUnusedObjects; 16 | @property (nonatomic, strong) NSMutableDictionary *dictionaryOfSetsOfUsedObjects; 17 | @property (nonatomic, strong) NSMutableDictionary *dictionaryOfRegisteredClassesOrNibs; 18 | - (id)newReuseObjectWithIdentifier:(NSString *)identifier; 19 | @end 20 | 21 | @implementation ACReuseQueue 22 | 23 | - (id)init { 24 | self = [super init]; 25 | if (self) { 26 | [[NSNotificationCenter defaultCenter] addObserver:self 27 | selector:@selector(removeAllUnusedObjects) 28 | name:UIApplicationDidReceiveMemoryWarningNotification 29 | object:nil]; 30 | } 31 | return self; 32 | } 33 | 34 | 35 | - (void)dealloc { 36 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 37 | } 38 | 39 | + (instancetype)defaultQueue { 40 | static ACReuseQueue *_reuseQueue; 41 | static dispatch_once_t onceToken; 42 | dispatch_once(&onceToken, ^{ 43 | _reuseQueue = [[ACReuseQueue alloc] init]; 44 | }); 45 | return _reuseQueue; 46 | } 47 | 48 | 49 | #pragma mark - private accessors 50 | 51 | - (NSMutableDictionary *)dictionaryOfSetsOfUnusedObjects { 52 | if (!_dictionaryOfSetsOfUnusedObjects) { 53 | _dictionaryOfSetsOfUnusedObjects = [[NSMutableDictionary alloc] init]; 54 | } 55 | return _dictionaryOfSetsOfUnusedObjects; 56 | } 57 | 58 | - (NSMutableDictionary *)dictionaryOfSetsOfUsedObjects { 59 | if (!_dictionaryOfSetsOfUsedObjects) { 60 | _dictionaryOfSetsOfUsedObjects = [[NSMutableDictionary alloc] init]; 61 | } 62 | return _dictionaryOfSetsOfUsedObjects; 63 | } 64 | 65 | - (NSMutableSet*)setOfUnusedObjectsWithIdentifier:(NSString*)identifier { 66 | NSMutableSet *unusedSet = self.dictionaryOfSetsOfUnusedObjects[identifier]; 67 | if (!unusedSet) { 68 | unusedSet = [[NSMutableSet alloc] init]; 69 | self.dictionaryOfSetsOfUnusedObjects[identifier] = unusedSet; 70 | } 71 | return unusedSet; 72 | } 73 | 74 | - (NSMutableSet*)setOfUsedObjectsWithIdentifier:(NSString*)identifier { 75 | NSMutableSet *usedSet = self.dictionaryOfSetsOfUsedObjects[identifier]; 76 | if (!usedSet) { 77 | usedSet = [[NSMutableSet alloc] init]; 78 | self.dictionaryOfSetsOfUsedObjects[identifier] = usedSet; 79 | } 80 | return usedSet; 81 | } 82 | 83 | - (NSMutableDictionary *)dictionaryOfRegisteredClassesOrNibs { 84 | if (!_dictionaryOfRegisteredClassesOrNibs) { 85 | _dictionaryOfRegisteredClassesOrNibs = [[NSMutableDictionary alloc] init]; 86 | } 87 | return _dictionaryOfRegisteredClassesOrNibs; 88 | } 89 | 90 | 91 | #pragma mark - counts 92 | 93 | - (NSUInteger)unusedCount { 94 | NSUInteger unusedCount = 0; 95 | for (NSSet *set in [self.dictionaryOfSetsOfUnusedObjects allValues]) { 96 | unusedCount += [set count]; 97 | } 98 | return unusedCount; 99 | } 100 | 101 | - (NSUInteger)usedCount { 102 | NSUInteger usedCount = 0; 103 | for (NSSet *set in [self.dictionaryOfSetsOfUsedObjects allValues]) { 104 | usedCount += [set count]; 105 | } 106 | return usedCount; 107 | } 108 | 109 | - (NSUInteger)count { 110 | return self.unusedCount + self.usedCount; 111 | } 112 | 113 | 114 | #pragma mark - Enqueueing and dequeuing objects 115 | 116 | - (void)enqueueReusableObject:(id)reusableObject { 117 | if (![reusableObject respondsToSelector:@selector(reuseIdentifier)] || 118 | !reusableObject.reuseIdentifier) return; 119 | 120 | [[self setOfUsedObjectsWithIdentifier:reusableObject.reuseIdentifier] removeObject:reusableObject]; 121 | [[self setOfUnusedObjectsWithIdentifier:reusableObject.reuseIdentifier] addObject:reusableObject]; 122 | } 123 | 124 | 125 | - (id)dequeueReusableObjectWithIdentifier:(NSString *)identifier { 126 | 127 | id reusableObject = [[self setOfUnusedObjectsWithIdentifier:identifier] anyObject]; 128 | 129 | if (!reusableObject) { 130 | reusableObject = [self newReuseObjectWithIdentifier:identifier]; 131 | 132 | if (reusableObject == nil) { 133 | [NSException raise:ACReuseQueueEmptyException format:@"No class or nib was registered with the ACReuseQueue for identifier %@", identifier]; 134 | } 135 | } 136 | 137 | [[self setOfUsedObjectsWithIdentifier:identifier] addObject:reusableObject]; 138 | [[self setOfUnusedObjectsWithIdentifier:identifier] removeObject:reusableObject]; 139 | 140 | if ([reusableObject respondsToSelector:@selector(prepareForReuse)]) { 141 | [reusableObject prepareForReuse]; 142 | } 143 | 144 | return reusableObject; 145 | } 146 | 147 | #pragma mark - Registring classes or nibs 148 | 149 | - (void)registerNib:(UINib *)nib forObjectReuseIdentifier:(NSString *)identifier { 150 | self.dictionaryOfRegisteredClassesOrNibs[identifier] = nib; 151 | } 152 | 153 | - (void)registerNibWithName:(NSString *)nibName bundle:(NSBundle *)nibBundle forObjectReuseIdentifier:(NSString *)identifier { 154 | [self registerNib:[UINib nibWithNibName:nibName bundle:nibBundle] forObjectReuseIdentifier:identifier]; 155 | } 156 | 157 | - (void)registerClass:(Class)objectClass forObjectReuseIdentifier:(NSString *)identifier { 158 | if (objectClass) { 159 | self.dictionaryOfRegisteredClassesOrNibs[identifier] = NSStringFromClass(objectClass); 160 | } else { 161 | [self.dictionaryOfRegisteredClassesOrNibs removeObjectForKey:identifier]; 162 | } 163 | } 164 | 165 | #pragma mark - creating objects 166 | 167 | - (id)newReuseObjectWithIdentifier:(NSString *)identifier { 168 | 169 | id object = nil; 170 | 171 | id classOrNib = self.dictionaryOfRegisteredClassesOrNibs[identifier]; 172 | 173 | if ([classOrNib isKindOfClass:NSString.class]) { 174 | Class cls = NSClassFromString(classOrNib); 175 | object = [cls alloc]; 176 | if ([object respondsToSelector:@selector(initWithReuseIdentifier:)]) { 177 | object = [object initWithReuseIdentifier:identifier]; 178 | } else { 179 | object = [object init]; 180 | if ([object respondsToSelector:@selector(setReuseIdentifier:)]) { 181 | [object setReuseIdentifier:identifier]; 182 | } 183 | } 184 | 185 | } else if ([classOrNib isKindOfClass:UINib.class]) { 186 | UINib *nib = (UINib*)classOrNib; 187 | NSArray *objects = [nib instantiateWithOwner:nil options:nil]; 188 | object = [objects lastObject]; 189 | if ([object respondsToSelector:@selector(setReuseIdentifier:)]) { 190 | [object setReuseIdentifier:identifier]; 191 | } 192 | } 193 | return object; 194 | } 195 | 196 | #pragma mark - remove objects 197 | 198 | 199 | - (void)removeAllUnusedObjects { 200 | [self.dictionaryOfSetsOfUnusedObjects removeAllObjects]; 201 | } 202 | 203 | @end 204 | -------------------------------------------------------------------------------- /ACReuseQueueDemo/ACAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // ACAppDelegate.h 3 | // ACReuseQueueDemo 4 | // 5 | // Created by Arnaud Coomans on 16/01/14. 6 | // Copyright (c) 2014 Arnaud Coomans. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ACAppDelegate : UIResponder 12 | @property (strong, nonatomic) UIWindow *window; 13 | @end 14 | -------------------------------------------------------------------------------- /ACReuseQueueDemo/ACAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // ACAppDelegate.m 3 | // ACReuseQueueDemo 4 | // 5 | // Created by Arnaud Coomans on 16/01/14. 6 | // Copyright (c) 2014 Arnaud Coomans. All rights reserved. 7 | // 8 | 9 | #import "ACAppDelegate.h" 10 | 11 | @implementation ACAppDelegate 12 | @end 13 | -------------------------------------------------------------------------------- /ACReuseQueueDemo/ACButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // ACButton.h 3 | // ACReuseQueueDemo 4 | // 5 | // Created by Arnaud Coomans on 16/01/14. 6 | // Copyright (c) 2014 Arnaud Coomans. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ACReuseQueue.h" 11 | 12 | @interface ACButton : UIButton 13 | @property (nonatomic, copy) NSString *reuseIdentifier; 14 | @end 15 | -------------------------------------------------------------------------------- /ACReuseQueueDemo/ACButton.m: -------------------------------------------------------------------------------- 1 | // 2 | // ACButton.m 3 | // ACReuseQueueDemo 4 | // 5 | // Created by Arnaud Coomans on 16/01/14. 6 | // Copyright (c) 2014 Arnaud Coomans. All rights reserved. 7 | // 8 | 9 | #import "ACButton.h" 10 | 11 | @implementation ACButton 12 | @end 13 | -------------------------------------------------------------------------------- /ACReuseQueueDemo/ACButton.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 18 | 19 | -------------------------------------------------------------------------------- /ACReuseQueueDemo/ACDataViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ACDataViewController.h 3 | // ACReuseQueueDemo 4 | // 5 | // Created by Arnaud Coomans on 16/01/14. 6 | // Copyright (c) 2014 Arnaud Coomans. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ACDataViewController : UIViewController 12 | @property (strong, nonatomic) IBOutlet UILabel *dataLabel; 13 | @property (assign, nonatomic) NSInteger number; 14 | @property (assign, nonatomic) BOOL useReuseQueue; 15 | @end 16 | -------------------------------------------------------------------------------- /ACReuseQueueDemo/ACDataViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ACDataViewController.m 3 | // ACReuseQueueDemo 4 | // 5 | // Created by Arnaud Coomans on 16/01/14. 6 | // Copyright (c) 2014 Arnaud Coomans. All rights reserved. 7 | // 8 | 9 | #import "ACDataViewController.h" 10 | 11 | #import "ACReuseQueue.h" 12 | #import "ACButton.h" 13 | 14 | 15 | @implementation ACDataViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | 20 | if (self.useReuseQueue) { 21 | 22 | [[ACReuseQueue defaultQueue] registerClass:ACButton.class forObjectReuseIdentifier:@"button"]; 23 | 24 | /*[[ACReuseQueue defaultQueue] registerNibWithName:NSStringFromClass(ACButton.class) 25 | bundle:nil 26 | forObjectReuseIdentifier:@"button"]; 27 | */ 28 | } 29 | } 30 | 31 | - (void)viewWillAppear:(BOOL)animated { 32 | [super viewWillAppear:animated]; 33 | self.dataLabel.text = [NSString stringWithFormat:@"%i", self.number]; 34 | 35 | CFAbsoluteTime startTime = CFAbsoluteTimeGetCurrent(); 36 | 37 | for (NSUInteger r = 200 + arc4random_uniform(10); r > 0; r-- ) { 38 | 39 | UIButton *button = nil; 40 | 41 | if (self.useReuseQueue) { 42 | button = (UIButton*)[[ACReuseQueue defaultQueue] dequeueReusableObjectWithIdentifier:@"button"]; 43 | } else { 44 | button = [UIButton buttonWithType:UIButtonTypeSystem]; 45 | } 46 | 47 | [button setTitle:@"hello" forState:UIControlStateNormal]; 48 | [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; 49 | 50 | button.frame = CGRectMake(50 + arc4random_uniform(self.view.bounds.size.width-140), 51 | 50 + arc4random_uniform(self.view.bounds.size.height-144), 52 | 40, 53 | 44); 54 | [self.view addSubview:button]; 55 | } 56 | 57 | CFAbsoluteTime elapsed = CFAbsoluteTimeGetCurrent() - startTime; 58 | NSLog(@"Elapsed Time: %0.3f seconds", elapsed); 59 | 60 | 61 | NSLog(@"(viewWillAppear:) defaultQueue count %u", [[ACReuseQueue defaultQueue] count]); 62 | } 63 | 64 | - (void)viewDidDisappear:(BOOL)animated { 65 | 66 | if (self.useReuseQueue) { 67 | for (ACButton *button in self.view.subviews) { 68 | [button removeFromSuperview]; 69 | [[ACReuseQueue defaultQueue] enqueueReusableObject:button]; 70 | } 71 | } 72 | 73 | NSLog(@"(viewDidDisappear:) defaultQueue count %u", [[ACReuseQueue defaultQueue] count]); 74 | 75 | [super viewDidDisappear:animated]; 76 | } 77 | 78 | @end 79 | -------------------------------------------------------------------------------- /ACReuseQueueDemo/ACPageViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ACPageViewController.h 3 | // ACReuseQueue 4 | // 5 | // Created by Arnaud Coomans on 24/01/14. 6 | // Copyright (c) 2014 Arnaud Coomans. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ACPageViewController : UIPageViewController 12 | @property (assign, nonatomic) BOOL useReuseQueue; 13 | @end 14 | -------------------------------------------------------------------------------- /ACReuseQueueDemo/ACPageViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ACPageViewController.m 3 | // ACReuseQueue 4 | // 5 | // Created by Arnaud Coomans on 24/01/14. 6 | // Copyright (c) 2014 Arnaud Coomans. All rights reserved. 7 | // 8 | 9 | #import "ACPageViewController.h" 10 | #import "ACDataViewController.h" 11 | 12 | 13 | @implementation ACPageViewController 14 | 15 | - (void)viewDidLoad { 16 | [super viewDidLoad]; 17 | 18 | self.delegate = self; 19 | self.dataSource = self; 20 | 21 | ACDataViewController *startingViewController = [self viewControllerAtIndex:0 storyboard:self.storyboard]; 22 | [self setViewControllers:@[startingViewController] 23 | direction:UIPageViewControllerNavigationDirectionForward 24 | animated:NO 25 | completion:nil]; 26 | } 27 | 28 | - (ACDataViewController *)viewControllerAtIndex:(NSUInteger)index storyboard:(UIStoryboard *)storyboard { 29 | ACDataViewController *dataViewController = [storyboard instantiateViewControllerWithIdentifier:NSStringFromClass(ACDataViewController.class)]; 30 | dataViewController.number = index; 31 | dataViewController.useReuseQueue = self.useReuseQueue; 32 | return dataViewController; 33 | } 34 | 35 | - (NSUInteger)indexOfViewController:(ACDataViewController *)viewController { 36 | return ((ACDataViewController*)viewController).number; 37 | } 38 | 39 | 40 | #pragma mark - Page View Controller Data Source 41 | 42 | - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController { 43 | NSUInteger index = [self indexOfViewController:(ACDataViewController *)viewController] - 1; 44 | return [self viewControllerAtIndex:index storyboard:viewController.storyboard]; 45 | } 46 | 47 | - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController { 48 | NSUInteger index = [self indexOfViewController:(ACDataViewController *)viewController] + 1; 49 | return [self viewControllerAtIndex:index storyboard:viewController.storyboard]; 50 | } 51 | 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /ACReuseQueueDemo/ACReuseQueueDemo-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.acoomans.${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.0 25 | LSRequiresIPhoneOS 26 | 27 | UIMainStoryboardFile 28 | Main_iPhone 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ACReuseQueueDemo/ACReuseQueueDemo-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /ACReuseQueueDemo/ACTableViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ACTableViewController.h 3 | // ACReuseQueue 4 | // 5 | // Created by Arnaud Coomans on 24/01/14. 6 | // Copyright (c) 2014 Arnaud Coomans. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ACTableViewController : UITableViewController 12 | @end 13 | -------------------------------------------------------------------------------- /ACReuseQueueDemo/ACTableViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ACTableViewController.m 3 | // ACReuseQueue 4 | // 5 | // Created by Arnaud Coomans on 24/01/14. 6 | // Copyright (c) 2014 Arnaud Coomans. All rights reserved. 7 | // 8 | 9 | #import "ACTableViewController.h" 10 | #import "ACPageViewController.h" 11 | 12 | @implementation ACTableViewController 13 | 14 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 15 | 16 | NSIndexPath *indexPath = [self.tableView indexPathForCell:sender]; 17 | switch (indexPath.row) { 18 | case 0: 19 | ((ACPageViewController*)segue.destinationViewController).useReuseQueue = NO; 20 | break; 21 | 22 | case 1: 23 | ((ACPageViewController*)segue.destinationViewController).useReuseQueue = YES; 24 | break; 25 | 26 | default: 27 | break; 28 | } 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /ACReuseQueueDemo/Base.lproj/Main_iPhone.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 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 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 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 | -------------------------------------------------------------------------------- /ACReuseQueueDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "ipad", 20 | "size" : "29x29", 21 | "scale" : "1x" 22 | }, 23 | { 24 | "idiom" : "ipad", 25 | "size" : "29x29", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "ipad", 30 | "size" : "40x40", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "40x40", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "76x76", 41 | "scale" : "1x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "76x76", 46 | "scale" : "2x" 47 | } 48 | ], 49 | "info" : { 50 | "version" : 1, 51 | "author" : "xcode" 52 | } 53 | } -------------------------------------------------------------------------------- /ACReuseQueueDemo/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "orientation" : "portrait", 20 | "idiom" : "ipad", 21 | "extent" : "full-screen", 22 | "minimum-system-version" : "7.0", 23 | "scale" : "1x" 24 | }, 25 | { 26 | "orientation" : "landscape", 27 | "idiom" : "ipad", 28 | "extent" : "full-screen", 29 | "minimum-system-version" : "7.0", 30 | "scale" : "1x" 31 | }, 32 | { 33 | "orientation" : "portrait", 34 | "idiom" : "ipad", 35 | "extent" : "full-screen", 36 | "minimum-system-version" : "7.0", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "orientation" : "landscape", 41 | "idiom" : "ipad", 42 | "extent" : "full-screen", 43 | "minimum-system-version" : "7.0", 44 | "scale" : "2x" 45 | } 46 | ], 47 | "info" : { 48 | "version" : 1, 49 | "author" : "xcode" 50 | } 51 | } -------------------------------------------------------------------------------- /ACReuseQueueDemo/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /ACReuseQueueDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ACReuseQueueDemo 4 | // 5 | // Created by Arnaud Coomans on 22/01/14. 6 | // Copyright (c) 2014 Arnaud Coomans. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "ACAppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([ACAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ACReuseQueueTests/ACReusableTest.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ACReuseQueueTests/ACReusableTestObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // ACReusableTestObject.h 3 | // ACReuseQueue 4 | // 5 | // Created by Arnaud Coomans on 22/01/14. 6 | // Copyright (c) 2014 Arnaud Coomans. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ACReusableObject.h" 11 | 12 | @interface ACReusableTestObject : NSObject 13 | @property (nonatomic, copy) NSString *reuseIdentifier; 14 | @property (nonatomic,copy) void(^prepareForReuseBlock)(); 15 | @end 16 | -------------------------------------------------------------------------------- /ACReuseQueueTests/ACReusableTestObject.m: -------------------------------------------------------------------------------- 1 | // 2 | // ACReusableTestObject.m 3 | // ACReuseQueue 4 | // 5 | // Created by Arnaud Coomans on 22/01/14. 6 | // Copyright (c) 2014 Arnaud Coomans. All rights reserved. 7 | // 8 | 9 | #import "ACReusableTestObject.h" 10 | 11 | @implementation ACReusableTestObject 12 | 13 | - (instancetype)initWithReuseIdentifier:(NSString*)identifier { 14 | self = [super init]; 15 | if (self) { 16 | _reuseIdentifier = identifier; 17 | } 18 | return self; 19 | } 20 | 21 | - (void)prepareForReuse { 22 | if (self.prepareForReuseBlock) { 23 | self.prepareForReuseBlock(); 24 | } 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /ACReuseQueueTests/ACReuseQueueTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.acoomans.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /ACReuseQueueTests/ACReuseQueueTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ACReuseQueueTests.m 3 | // ACReuseQueueTests 4 | // 5 | // Created by Arnaud Coomans on 22/01/14. 6 | // Copyright (c) 2014 Arnaud Coomans. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ACReuseQueue.h" 11 | #import "ACReusableTestObject.h" 12 | 13 | 14 | static NSString * const kReuseIdentifierA = @"kReuseIdentifierA"; 15 | static NSString * const kReuseIdentifierB = @"kReuseIdentifierB"; 16 | 17 | 18 | @interface ACReuseQueueTests : XCTestCase 19 | 20 | @end 21 | 22 | @implementation ACReuseQueueTests 23 | 24 | - (void)setUp { 25 | [super setUp]; 26 | // 27 | } 28 | 29 | - (void)tearDown { 30 | // 31 | [super tearDown]; 32 | } 33 | 34 | #pragma mark - default queue 35 | 36 | - (void)testDefaultQueue { 37 | 38 | ACReuseQueue *q = [ACReuseQueue defaultQueue]; 39 | 40 | XCTAssertNotNil(q, @"No default queue"); 41 | 42 | XCTAssertTrue(q.unusedCount == 0); 43 | XCTAssertTrue(q.usedCount == 0); 44 | XCTAssertTrue(q.count == 0); 45 | } 46 | 47 | 48 | #pragma mark - enqueue 49 | 50 | - (void)testEnqueue { 51 | ACReuseQueue *q = [[ACReuseQueue alloc] init]; 52 | 53 | [q enqueueReusableObject:[[ACReusableTestObject alloc] initWithReuseIdentifier:kReuseIdentifierA]]; 54 | 55 | XCTAssertTrue(q.unusedCount == 1); 56 | XCTAssertTrue(q.usedCount == 0); 57 | XCTAssertTrue(q.count == 1); 58 | 59 | [q enqueueReusableObject:[[ACReusableTestObject alloc] initWithReuseIdentifier:kReuseIdentifierA]]; 60 | 61 | XCTAssertTrue(q.unusedCount == 2); 62 | XCTAssertTrue(q.usedCount == 0); 63 | XCTAssertTrue(q.count == 2); 64 | } 65 | 66 | - (void)testEnqueueWithMultipleIdentifiers { 67 | ACReuseQueue *q = [[ACReuseQueue alloc] init]; 68 | 69 | [q enqueueReusableObject:[[ACReusableTestObject alloc] initWithReuseIdentifier:kReuseIdentifierA]]; 70 | 71 | XCTAssertTrue(q.unusedCount == 1); 72 | XCTAssertTrue(q.usedCount == 0); 73 | XCTAssertTrue(q.count == 1); 74 | 75 | [q enqueueReusableObject:[[ACReusableTestObject alloc] initWithReuseIdentifier:kReuseIdentifierB]]; 76 | 77 | XCTAssertTrue(q.unusedCount == 2); 78 | XCTAssertTrue(q.usedCount == 0); 79 | XCTAssertTrue(q.count == 2); 80 | } 81 | 82 | - (void)testEnqueueWithoutIdentifier { 83 | ACReuseQueue *q = [[ACReuseQueue alloc] init]; 84 | 85 | [q enqueueReusableObject:[[ACReusableTestObject alloc] initWithReuseIdentifier:nil]]; 86 | 87 | XCTAssertTrue(q.unusedCount == 0); 88 | XCTAssertTrue(q.usedCount == 0); 89 | XCTAssertTrue(q.count == 0); 90 | } 91 | 92 | 93 | 94 | #pragma mark - dequeue 95 | 96 | - (void)testDequeue { 97 | ACReuseQueue *q = [[ACReuseQueue alloc] init]; 98 | 99 | 100 | [q enqueueReusableObject:[[ACReusableTestObject alloc] initWithReuseIdentifier:kReuseIdentifierA]]; 101 | 102 | XCTAssertTrue(q.unusedCount == 1); 103 | XCTAssertTrue(q.usedCount == 0); 104 | XCTAssertTrue(q.count == 1); 105 | 106 | [q dequeueReusableObjectWithIdentifier:kReuseIdentifierA]; 107 | 108 | XCTAssertTrue(q.unusedCount == 0); 109 | XCTAssertTrue(q.usedCount == 1); 110 | XCTAssertTrue(q.count == 1); 111 | 112 | [q enqueueReusableObject:[[ACReusableTestObject alloc] initWithReuseIdentifier:kReuseIdentifierA]]; 113 | 114 | XCTAssertTrue(q.unusedCount == 1); 115 | XCTAssertTrue(q.usedCount == 1); 116 | XCTAssertTrue(q.count == 2); 117 | 118 | [q dequeueReusableObjectWithIdentifier:kReuseIdentifierA]; 119 | 120 | XCTAssertTrue(q.unusedCount == 0); 121 | XCTAssertTrue(q.usedCount == 2); 122 | XCTAssertTrue(q.count == 2); 123 | } 124 | 125 | - (void)testDequeueWithMultipleIdentifiers { 126 | ACReuseQueue *q = [[ACReuseQueue alloc] init]; 127 | 128 | [q enqueueReusableObject:[[ACReusableTestObject alloc] initWithReuseIdentifier:kReuseIdentifierA]]; 129 | 130 | XCTAssertTrue(q.unusedCount == 1); 131 | XCTAssertTrue(q.usedCount == 0); 132 | XCTAssertTrue(q.count == 1); 133 | 134 | id r = [q dequeueReusableObjectWithIdentifier:kReuseIdentifierA]; 135 | 136 | XCTAssertEqualObjects(r.reuseIdentifier, kReuseIdentifierA); 137 | 138 | XCTAssertTrue(q.unusedCount == 0); 139 | XCTAssertTrue(q.usedCount == 1); 140 | XCTAssertTrue(q.count == 1); 141 | 142 | [q enqueueReusableObject:[[ACReusableTestObject alloc] initWithReuseIdentifier:kReuseIdentifierB]]; 143 | 144 | XCTAssertTrue(q.unusedCount == 1); 145 | XCTAssertTrue(q.usedCount == 1); 146 | XCTAssertTrue(q.count == 2); 147 | 148 | r = [q dequeueReusableObjectWithIdentifier:kReuseIdentifierB]; 149 | 150 | XCTAssertEqualObjects(r.reuseIdentifier, kReuseIdentifierB); 151 | 152 | XCTAssertTrue(q.unusedCount == 0); 153 | XCTAssertTrue(q.usedCount == 2); 154 | XCTAssertTrue(q.count == 2); 155 | } 156 | 157 | - (void)testPrepareForReuse { 158 | 159 | __block BOOL blockDidRun = NO; 160 | 161 | ACReuseQueue *q = [[ACReuseQueue alloc] init]; 162 | 163 | ACReusableTestObject *r = [[ACReusableTestObject alloc] initWithReuseIdentifier:kReuseIdentifierA]; 164 | r.prepareForReuseBlock = ^{ 165 | blockDidRun = YES; 166 | }; 167 | 168 | [q enqueueReusableObject:r]; 169 | XCTAssertFalse(blockDidRun); 170 | 171 | [q dequeueReusableObjectWithIdentifier:kReuseIdentifierA]; 172 | XCTAssertTrue(blockDidRun); 173 | } 174 | 175 | - (void)testDequeueEmpty { 176 | 177 | ACReuseQueue *q = [[ACReuseQueue alloc] init]; 178 | 179 | @try { 180 | [q dequeueReusableObjectWithIdentifier:kReuseIdentifierA]; 181 | XCTAssertTrue(NO); 182 | } 183 | @catch (NSException *exception) { 184 | XCTAssertEqualObjects(exception.name, ACReuseQueueEmptyException); 185 | } 186 | } 187 | 188 | - (void)testDequeueEmptyForIdentifier { 189 | 190 | ACReuseQueue *q = [[ACReuseQueue alloc] init]; 191 | 192 | [q enqueueReusableObject:[[ACReusableTestObject alloc] initWithReuseIdentifier:kReuseIdentifierA]]; 193 | 194 | @try { 195 | [q dequeueReusableObjectWithIdentifier:kReuseIdentifierB]; 196 | XCTAssertTrue(NO); 197 | } 198 | @catch (NSException *exception) { 199 | XCTAssertEqualObjects(exception.name, ACReuseQueueEmptyException); 200 | } 201 | } 202 | 203 | - (void)testDequeueEmptied { 204 | 205 | ACReuseQueue *q = [[ACReuseQueue alloc] init]; 206 | 207 | [q enqueueReusableObject:[[ACReusableTestObject alloc] initWithReuseIdentifier:kReuseIdentifierA]]; 208 | [q dequeueReusableObjectWithIdentifier:kReuseIdentifierA]; 209 | 210 | @try { 211 | [q dequeueReusableObjectWithIdentifier:kReuseIdentifierA]; 212 | XCTAssertTrue(NO); 213 | } 214 | @catch (NSException *exception) { 215 | XCTAssertEqualObjects(exception.name, ACReuseQueueEmptyException); 216 | } 217 | } 218 | 219 | 220 | #pragma - register 221 | 222 | - (void)testRegisterClass { 223 | 224 | ACReuseQueue *q = [[ACReuseQueue alloc] init]; 225 | [q registerClass:ACReusableTestObject.class forObjectReuseIdentifier:kReuseIdentifierA]; 226 | 227 | ACReusableTestObject *r = [q dequeueReusableObjectWithIdentifier:kReuseIdentifierA]; 228 | XCTAssertNotNil(r); 229 | XCTAssertEqualObjects(r.reuseIdentifier, kReuseIdentifierA); 230 | XCTAssertTrue([r isKindOfClass:ACReusableTestObject.class]); 231 | 232 | @try { 233 | [q dequeueReusableObjectWithIdentifier:kReuseIdentifierB]; 234 | XCTAssertTrue(NO); 235 | } 236 | @catch (NSException *exception) { 237 | XCTAssertEqualObjects(exception.name, ACReuseQueueEmptyException); 238 | } 239 | } 240 | 241 | - (void)testRegisterNib { 242 | 243 | // hack for tests 244 | __block NSBundle *bundleContainingNib = nil; 245 | [[NSBundle allBundles] enumerateObjectsUsingBlock:^(NSBundle *bundle, NSUInteger idx, BOOL *stop) { 246 | NSString *locatedPath = [bundle pathForResource:@"ACReusableTest" ofType:@"nib"]; 247 | if (locatedPath) { 248 | bundleContainingNib = bundle; 249 | *stop = YES; 250 | } 251 | }]; 252 | // end hack for tests 253 | 254 | ACReuseQueue *q = [[ACReuseQueue alloc] init]; 255 | [q registerNib:[UINib nibWithNibName:@"ACReusableTest" bundle:bundleContainingNib] forObjectReuseIdentifier:kReuseIdentifierA]; 256 | 257 | ACReusableTestObject *r = [q dequeueReusableObjectWithIdentifier:kReuseIdentifierA]; 258 | XCTAssertNotNil(r); 259 | XCTAssertEqualObjects(r.reuseIdentifier, kReuseIdentifierA); 260 | XCTAssertTrue([r isKindOfClass:ACReusableTestObject.class]); 261 | 262 | @try { 263 | [q dequeueReusableObjectWithIdentifier:kReuseIdentifierB]; 264 | XCTAssertTrue(NO); 265 | } 266 | @catch (NSException *exception) { 267 | XCTAssertEqualObjects(exception.name, ACReuseQueueEmptyException); 268 | } 269 | } 270 | 271 | - (void)testMemoryWarning { 272 | 273 | ACReuseQueue *q = [[ACReuseQueue alloc] init]; 274 | [q enqueueReusableObject:[[ACReusableTestObject alloc] initWithReuseIdentifier:kReuseIdentifierA]]; 275 | [q enqueueReusableObject:[[ACReusableTestObject alloc] initWithReuseIdentifier:kReuseIdentifierA]]; 276 | [q enqueueReusableObject:[[ACReusableTestObject alloc] initWithReuseIdentifier:kReuseIdentifierA]]; 277 | 278 | [q dequeueReusableObjectWithIdentifier:kReuseIdentifierA]; 279 | 280 | XCTAssertTrue(q.unusedCount == 2); 281 | XCTAssertTrue(q.usedCount == 1); 282 | XCTAssertTrue(q.count == 3); 283 | 284 | [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidReceiveMemoryWarningNotification object:nil]; 285 | 286 | XCTAssertTrue(q.unusedCount == 0); 287 | XCTAssertTrue(q.usedCount == 1); 288 | XCTAssertTrue(q.count == 1); 289 | 290 | 291 | } 292 | 293 | 294 | 295 | @end 296 | -------------------------------------------------------------------------------- /ACReuseQueueTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Arnaud Coomans 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ACReuseQueue 2 | 3 | A queue to keep and reusing objects. 4 | 5 | A reuse queue is a way to quickly reuse objects when object allocation and initialization is time-consuming. 6 | This reuse queue is inspired after UITableView's for reusing cells, headers and footers. 7 | 8 | [![Build Status](https://api.travis-ci.org/acoomans/ACReuseQueue.png)](https://api.travis-ci.org/acoomans/ACReuseQueue.png) 9 | [![Cocoapods](https://cocoapod-badges.herokuapp.com/v/ACReuseQueue/badge.png)](http://beta.cocoapods.org/?q=on%3Aios%20name%3AACReuseQueue%2A) 10 | [![Cocoapods](https://cocoapod-badges.herokuapp.com/p/ACReuseQueue/badge.png)](http://beta.cocoapods.org/?q=on%3Aios%20name%3AACReuseQueue%2A) 11 | 12 | 13 | ## Install 14 | 15 | You can either clone this repository and add the files in the `ACReuseQueue` directory to your project; or use [CocoaPods](http://cocoapods.org). 16 | 17 | Add a pod entry to your Podfile: 18 | 19 | ```ruby 20 | pod 'ACReuseQueue', '~> 0.0.1' 21 | ``` 22 | 23 | Install the pod(s) by running: 24 | 25 | ```ruby 26 | pod install 27 | ``` 28 | 29 | 30 | ## Usage 31 | 32 | ### Reuse queue 33 | 34 | You can then use the default queue with: 35 | 36 | ```objc 37 | ACReuseQueue *myQueue = [ACReuseQueue defaultQueue]; 38 | ``` 39 | 40 | or allocate and initialize your own queue. 41 | 42 | To reuse an object, call `dequeueReusableObjectWithIdentifier:` 43 | 44 | ```objc 45 | [myQueue dequeueReusableObjectWithIdentifier:@"myIdentifier"]; 46 | ``` 47 | 48 | When you are done using an object, return it to the queue with `enqueueReusableObject:` 49 | 50 | ```objc 51 | [myQueue enqueueReusableObject:myObject]; 52 | ``` 53 | 54 | ### Reusable object 55 | 56 | To be reused, an object must conform to the `ACReusableObject` and must implement the `reuseIdentifier` 57 | 58 | ```objc 59 | @property (nonatomic, copy) NSString *reuseIdentifier; 60 | ``` 61 | 62 | If an object may implement the `prepareForReuse` method, it will be called before the object is returned by `dequeueReusableObjectWithIdentifier:` 63 | 64 | 65 | ### Registering a class or a nib 66 | 67 | You can register a class or a nib for a given identifier with `registerClass:forObjectReuseIdentifier:` or `registerNib:forObjectReuseIdentifier:`. It will automatically create an object for you if no object is available when dequeueing: 68 | 69 | ```objc 70 | [[ACReuseQueue defaultQueue] registerClass:ACButton.class forObjectReuseIdentifier:@"button"]; 71 | ``` 72 | 73 | or 74 | 75 | ```objc 76 | [[ACReuseQueue defaultQueue] registerNibWithName:NSStringFromClass(ACButton.class) 77 | bundle:nil 78 | forObjectReuseIdentifier:@"button"]; 79 | ``` 80 | 81 | ## Documentation 82 | 83 | If you have [appledoc](http://gentlebytes.com/appledoc/) installed, you can generate the documentation by running the corresponding target. 84 | 85 | ## Demo 86 | 87 | The `ACReuseQueueDemo` target contains an example application to compare the performance with and without the reuse queue. You should preferably run the app on an actual device. 88 | 89 | The demo app has a page view controller, where each page contains about 200 buttons (I know the example is a little bit contrived but it serves to expose the performance difference). Swipe both fast and slowly to appreciate the difference. 90 | 91 | Here are results of my tests on a ipad mini (note: your performance may vary): 92 | 93 | a) without a reuse queue: 94 | 95 | * a page is rendered in approximately 0.2 seconds 96 | 97 | b) with a reuse queue: 98 | 99 | * the first and second page are rendered in approximately 0.2 seconds as well, BUT 100 | * the next pages are rendered in 0.015 seconds (because it can reuse the buttons) 101 | 102 | --------------------------------------------------------------------------------