├── LICENSE ├── README.md ├── YBArchiveUtilDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ └── wangyingbo.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── wangyingbo.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ └── xcschememanagement.plist ├── YBArchiveUtilDemo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── Person.h ├── Person.m ├── ViewController.h ├── ViewController.m ├── YBArchiveUtil │ ├── YBArchiveTool.h │ ├── YBArchiveTool.m │ ├── YBArchiveUtil.h │ ├── YBArchiveUtil.m │ ├── YBArchiveUtilHeader.h │ ├── YBAutoArchive.h │ └── YBAutoArchive.m └── main.m ├── YBArchiveUtilDemoTests ├── Info.plist └── YBArchiveUtilDemoTests.m ├── YBArchiveUtilDemoUITests ├── Info.plist └── YBArchiveUtilDemoUITests.m └── screenshot.png /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 王颖博 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # YBArchiveUtilDemo 2 | 归档解档的工具 3 | 4 | screenShot1 5 | 6 | > 工具类实现归档解档 7 | 8 | ## 需要被归档的model类可继承`YBAutoArchive`,也可不继承基类,只需在自己的model类的.m文件的`@implementation`和`@end`之间实现里添加宏`YB_IMPLEMENTATION_CODE_WITH_CODER`。 9 | 10 | + 可全局配置保存的文件路径名,调用`setPlistPathName :`方法; 11 | + 也可以设置单独归档的文件名,调用`saveObject:withFilePathName:`或者`saveObjects:forFlag:withFilePathName`方法; 12 | + 调用`saveObject:withFilePathName:`和`saveObjects:forFlag:withFilePathName`方法的区别是归档单个或者多个model; 13 | + 移除时调用`removeObjectWithFilePathName:`方法。 14 | 15 | 16 | 17 | 方法如下: 18 | 19 | /** 20 | 指定默认保存数据的文件名,全局只用设置一次 21 | 22 | @param pathName 文件名 23 | */ 24 | + (void)setPlistPathName:(NSString*)pathName; 25 | 26 | /** 27 | 保存单个数据 28 | 29 | @param obj 实现了归档的对象 30 | @param filePathName 文件名,如果传值nil,则会保存在默认的defaultPathName里 31 | @return 保存状态 32 | */ 33 | + (BOOL)saveObject:(id)obj withFilePathName:(NSString *)filePathName; 34 | 35 | /** 36 | 取出单个数据 37 | 38 | @param filePathName 文件名,如果传值nil,则会在默认的defaultPathName里取 39 | @return 对象 40 | */ 41 | + (id)getObjectWithFilePathName:(NSString *)filePathName; 42 | 43 | /** 44 | 移除文件名下的对象 45 | 46 | @param filePathName 文件名,如果传值nil,则return 47 | @return 执行结果 48 | */ 49 | + (BOOL)removeObjectWithFilePathName:(NSString *)filePathName; 50 | 51 | /** 52 | 保存多个数据 53 | 54 | @param objs 多个数据数组 55 | @param flag flag description 56 | @param filePathName 文件名,如果传值nil,则会保存在默认的defaultPathName里 57 | @return 保存状态 58 | */ 59 | + (BOOL)saveObjects:(NSArray *)objs forFlag:(NSString*)flag withFilePathName:(NSString *)filePathName; 60 | 61 | /** 62 | 取多个数据 63 | 64 | @param flag flag description 65 | @param filePathName 文件名,如果传值nil,则会在默认的defaultPathName里取 66 | @return 多个数据的数组 67 | */ 68 | + (NSArray *)getObjectsForFlag:(NSString*)flag withFilePathName:(NSString *)filePathName; 69 | 70 | 71 | ## 可修改`extern BOOL YBDebugAssertionsShouldBreak;`代码里的`YBDebugAssertionsShouldBreak `的值,这个值的作用是当遇到自定义的断言`YBDASSERT`时,是否需要断点定位到代码行。 72 | -------------------------------------------------------------------------------- /YBArchiveUtilDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 03B9B37F20B7A2C000BEE366 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 03B9B37E20B7A2C000BEE366 /* AppDelegate.m */; }; 11 | 03B9B38220B7A2C000BEE366 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 03B9B38120B7A2C000BEE366 /* ViewController.m */; }; 12 | 03B9B38520B7A2C000BEE366 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 03B9B38320B7A2C000BEE366 /* Main.storyboard */; }; 13 | 03B9B38720B7A2C200BEE366 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 03B9B38620B7A2C200BEE366 /* Assets.xcassets */; }; 14 | 03B9B38A20B7A2C200BEE366 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 03B9B38820B7A2C200BEE366 /* LaunchScreen.storyboard */; }; 15 | 03B9B38D20B7A2C200BEE366 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 03B9B38C20B7A2C200BEE366 /* main.m */; }; 16 | 03B9B39720B7A2C200BEE366 /* YBArchiveUtilDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 03B9B39620B7A2C200BEE366 /* YBArchiveUtilDemoTests.m */; }; 17 | 03B9B3A220B7A2C200BEE366 /* YBArchiveUtilDemoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 03B9B3A120B7A2C200BEE366 /* YBArchiveUtilDemoUITests.m */; }; 18 | 03B9B3B220B7A32800BEE366 /* YBAutoArchive.m in Sources */ = {isa = PBXBuildFile; fileRef = 03B9B3B120B7A32800BEE366 /* YBAutoArchive.m */; }; 19 | 03B9B3B520B7A3B400BEE366 /* YBArchiveUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 03B9B3B420B7A3B400BEE366 /* YBArchiveUtil.m */; }; 20 | 03B9B3B920B7C78E00BEE366 /* Person.m in Sources */ = {isa = PBXBuildFile; fileRef = 03B9B3B820B7C78E00BEE366 /* Person.m */; }; 21 | 03B9B3BC20B7D3C400BEE366 /* YBArchiveTool.m in Sources */ = {isa = PBXBuildFile; fileRef = 03B9B3BB20B7D3C400BEE366 /* YBArchiveTool.m */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXContainerItemProxy section */ 25 | 03B9B39320B7A2C200BEE366 /* PBXContainerItemProxy */ = { 26 | isa = PBXContainerItemProxy; 27 | containerPortal = 03B9B37220B7A2C000BEE366 /* Project object */; 28 | proxyType = 1; 29 | remoteGlobalIDString = 03B9B37920B7A2C000BEE366; 30 | remoteInfo = YBArchiveUtilDemo; 31 | }; 32 | 03B9B39E20B7A2C200BEE366 /* PBXContainerItemProxy */ = { 33 | isa = PBXContainerItemProxy; 34 | containerPortal = 03B9B37220B7A2C000BEE366 /* Project object */; 35 | proxyType = 1; 36 | remoteGlobalIDString = 03B9B37920B7A2C000BEE366; 37 | remoteInfo = YBArchiveUtilDemo; 38 | }; 39 | /* End PBXContainerItemProxy section */ 40 | 41 | /* Begin PBXFileReference section */ 42 | 03B9B37A20B7A2C000BEE366 /* YBArchiveUtilDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YBArchiveUtilDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | 03B9B37D20B7A2C000BEE366 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 44 | 03B9B37E20B7A2C000BEE366 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 45 | 03B9B38020B7A2C000BEE366 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 46 | 03B9B38120B7A2C000BEE366 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 47 | 03B9B38420B7A2C000BEE366 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 48 | 03B9B38620B7A2C200BEE366 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 49 | 03B9B38920B7A2C200BEE366 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 50 | 03B9B38B20B7A2C200BEE366 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 51 | 03B9B38C20B7A2C200BEE366 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 52 | 03B9B39220B7A2C200BEE366 /* YBArchiveUtilDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = YBArchiveUtilDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | 03B9B39620B7A2C200BEE366 /* YBArchiveUtilDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = YBArchiveUtilDemoTests.m; sourceTree = ""; }; 54 | 03B9B39820B7A2C200BEE366 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 55 | 03B9B39D20B7A2C200BEE366 /* YBArchiveUtilDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = YBArchiveUtilDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 56 | 03B9B3A120B7A2C200BEE366 /* YBArchiveUtilDemoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = YBArchiveUtilDemoUITests.m; sourceTree = ""; }; 57 | 03B9B3A320B7A2C200BEE366 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 58 | 03B9B3B020B7A32800BEE366 /* YBAutoArchive.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YBAutoArchive.h; sourceTree = ""; }; 59 | 03B9B3B120B7A32800BEE366 /* YBAutoArchive.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = YBAutoArchive.m; sourceTree = ""; }; 60 | 03B9B3B320B7A3B400BEE366 /* YBArchiveUtil.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YBArchiveUtil.h; sourceTree = ""; }; 61 | 03B9B3B420B7A3B400BEE366 /* YBArchiveUtil.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = YBArchiveUtil.m; sourceTree = ""; }; 62 | 03B9B3B620B7A71100BEE366 /* YBArchiveUtilHeader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YBArchiveUtilHeader.h; sourceTree = ""; }; 63 | 03B9B3B720B7C78E00BEE366 /* Person.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Person.h; sourceTree = ""; }; 64 | 03B9B3B820B7C78E00BEE366 /* Person.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Person.m; sourceTree = ""; }; 65 | 03B9B3BA20B7D3C400BEE366 /* YBArchiveTool.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YBArchiveTool.h; sourceTree = ""; }; 66 | 03B9B3BB20B7D3C400BEE366 /* YBArchiveTool.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = YBArchiveTool.m; sourceTree = ""; }; 67 | /* End PBXFileReference section */ 68 | 69 | /* Begin PBXFrameworksBuildPhase section */ 70 | 03B9B37720B7A2C000BEE366 /* Frameworks */ = { 71 | isa = PBXFrameworksBuildPhase; 72 | buildActionMask = 2147483647; 73 | files = ( 74 | ); 75 | runOnlyForDeploymentPostprocessing = 0; 76 | }; 77 | 03B9B38F20B7A2C200BEE366 /* Frameworks */ = { 78 | isa = PBXFrameworksBuildPhase; 79 | buildActionMask = 2147483647; 80 | files = ( 81 | ); 82 | runOnlyForDeploymentPostprocessing = 0; 83 | }; 84 | 03B9B39A20B7A2C200BEE366 /* Frameworks */ = { 85 | isa = PBXFrameworksBuildPhase; 86 | buildActionMask = 2147483647; 87 | files = ( 88 | ); 89 | runOnlyForDeploymentPostprocessing = 0; 90 | }; 91 | /* End PBXFrameworksBuildPhase section */ 92 | 93 | /* Begin PBXGroup section */ 94 | 03B9B37120B7A2C000BEE366 = { 95 | isa = PBXGroup; 96 | children = ( 97 | 03B9B37C20B7A2C000BEE366 /* YBArchiveUtilDemo */, 98 | 03B9B39520B7A2C200BEE366 /* YBArchiveUtilDemoTests */, 99 | 03B9B3A020B7A2C200BEE366 /* YBArchiveUtilDemoUITests */, 100 | 03B9B37B20B7A2C000BEE366 /* Products */, 101 | ); 102 | sourceTree = ""; 103 | }; 104 | 03B9B37B20B7A2C000BEE366 /* Products */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | 03B9B37A20B7A2C000BEE366 /* YBArchiveUtilDemo.app */, 108 | 03B9B39220B7A2C200BEE366 /* YBArchiveUtilDemoTests.xctest */, 109 | 03B9B39D20B7A2C200BEE366 /* YBArchiveUtilDemoUITests.xctest */, 110 | ); 111 | name = Products; 112 | sourceTree = ""; 113 | }; 114 | 03B9B37C20B7A2C000BEE366 /* YBArchiveUtilDemo */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | 03B9B3AF20B7A30900BEE366 /* YBArchiveUtil */, 118 | 03B9B37D20B7A2C000BEE366 /* AppDelegate.h */, 119 | 03B9B37E20B7A2C000BEE366 /* AppDelegate.m */, 120 | 03B9B38020B7A2C000BEE366 /* ViewController.h */, 121 | 03B9B38120B7A2C000BEE366 /* ViewController.m */, 122 | 03B9B3B720B7C78E00BEE366 /* Person.h */, 123 | 03B9B3B820B7C78E00BEE366 /* Person.m */, 124 | 03B9B38320B7A2C000BEE366 /* Main.storyboard */, 125 | 03B9B38620B7A2C200BEE366 /* Assets.xcassets */, 126 | 03B9B38820B7A2C200BEE366 /* LaunchScreen.storyboard */, 127 | 03B9B38B20B7A2C200BEE366 /* Info.plist */, 128 | 03B9B38C20B7A2C200BEE366 /* main.m */, 129 | ); 130 | path = YBArchiveUtilDemo; 131 | sourceTree = ""; 132 | }; 133 | 03B9B39520B7A2C200BEE366 /* YBArchiveUtilDemoTests */ = { 134 | isa = PBXGroup; 135 | children = ( 136 | 03B9B39620B7A2C200BEE366 /* YBArchiveUtilDemoTests.m */, 137 | 03B9B39820B7A2C200BEE366 /* Info.plist */, 138 | ); 139 | path = YBArchiveUtilDemoTests; 140 | sourceTree = ""; 141 | }; 142 | 03B9B3A020B7A2C200BEE366 /* YBArchiveUtilDemoUITests */ = { 143 | isa = PBXGroup; 144 | children = ( 145 | 03B9B3A120B7A2C200BEE366 /* YBArchiveUtilDemoUITests.m */, 146 | 03B9B3A320B7A2C200BEE366 /* Info.plist */, 147 | ); 148 | path = YBArchiveUtilDemoUITests; 149 | sourceTree = ""; 150 | }; 151 | 03B9B3AF20B7A30900BEE366 /* YBArchiveUtil */ = { 152 | isa = PBXGroup; 153 | children = ( 154 | 03B9B3B020B7A32800BEE366 /* YBAutoArchive.h */, 155 | 03B9B3B120B7A32800BEE366 /* YBAutoArchive.m */, 156 | 03B9B3B320B7A3B400BEE366 /* YBArchiveUtil.h */, 157 | 03B9B3B420B7A3B400BEE366 /* YBArchiveUtil.m */, 158 | 03B9B3BA20B7D3C400BEE366 /* YBArchiveTool.h */, 159 | 03B9B3BB20B7D3C400BEE366 /* YBArchiveTool.m */, 160 | 03B9B3B620B7A71100BEE366 /* YBArchiveUtilHeader.h */, 161 | ); 162 | path = YBArchiveUtil; 163 | sourceTree = ""; 164 | }; 165 | /* End PBXGroup section */ 166 | 167 | /* Begin PBXNativeTarget section */ 168 | 03B9B37920B7A2C000BEE366 /* YBArchiveUtilDemo */ = { 169 | isa = PBXNativeTarget; 170 | buildConfigurationList = 03B9B3A620B7A2C200BEE366 /* Build configuration list for PBXNativeTarget "YBArchiveUtilDemo" */; 171 | buildPhases = ( 172 | 03B9B37620B7A2C000BEE366 /* Sources */, 173 | 03B9B37720B7A2C000BEE366 /* Frameworks */, 174 | 03B9B37820B7A2C000BEE366 /* Resources */, 175 | ); 176 | buildRules = ( 177 | ); 178 | dependencies = ( 179 | ); 180 | name = YBArchiveUtilDemo; 181 | productName = YBArchiveUtilDemo; 182 | productReference = 03B9B37A20B7A2C000BEE366 /* YBArchiveUtilDemo.app */; 183 | productType = "com.apple.product-type.application"; 184 | }; 185 | 03B9B39120B7A2C200BEE366 /* YBArchiveUtilDemoTests */ = { 186 | isa = PBXNativeTarget; 187 | buildConfigurationList = 03B9B3A920B7A2C200BEE366 /* Build configuration list for PBXNativeTarget "YBArchiveUtilDemoTests" */; 188 | buildPhases = ( 189 | 03B9B38E20B7A2C200BEE366 /* Sources */, 190 | 03B9B38F20B7A2C200BEE366 /* Frameworks */, 191 | 03B9B39020B7A2C200BEE366 /* Resources */, 192 | ); 193 | buildRules = ( 194 | ); 195 | dependencies = ( 196 | 03B9B39420B7A2C200BEE366 /* PBXTargetDependency */, 197 | ); 198 | name = YBArchiveUtilDemoTests; 199 | productName = YBArchiveUtilDemoTests; 200 | productReference = 03B9B39220B7A2C200BEE366 /* YBArchiveUtilDemoTests.xctest */; 201 | productType = "com.apple.product-type.bundle.unit-test"; 202 | }; 203 | 03B9B39C20B7A2C200BEE366 /* YBArchiveUtilDemoUITests */ = { 204 | isa = PBXNativeTarget; 205 | buildConfigurationList = 03B9B3AC20B7A2C200BEE366 /* Build configuration list for PBXNativeTarget "YBArchiveUtilDemoUITests" */; 206 | buildPhases = ( 207 | 03B9B39920B7A2C200BEE366 /* Sources */, 208 | 03B9B39A20B7A2C200BEE366 /* Frameworks */, 209 | 03B9B39B20B7A2C200BEE366 /* Resources */, 210 | ); 211 | buildRules = ( 212 | ); 213 | dependencies = ( 214 | 03B9B39F20B7A2C200BEE366 /* PBXTargetDependency */, 215 | ); 216 | name = YBArchiveUtilDemoUITests; 217 | productName = YBArchiveUtilDemoUITests; 218 | productReference = 03B9B39D20B7A2C200BEE366 /* YBArchiveUtilDemoUITests.xctest */; 219 | productType = "com.apple.product-type.bundle.ui-testing"; 220 | }; 221 | /* End PBXNativeTarget section */ 222 | 223 | /* Begin PBXProject section */ 224 | 03B9B37220B7A2C000BEE366 /* Project object */ = { 225 | isa = PBXProject; 226 | attributes = { 227 | LastUpgradeCheck = 0930; 228 | ORGANIZATIONNAME = "王颖博"; 229 | TargetAttributes = { 230 | 03B9B37920B7A2C000BEE366 = { 231 | CreatedOnToolsVersion = 9.3; 232 | }; 233 | 03B9B39120B7A2C200BEE366 = { 234 | CreatedOnToolsVersion = 9.3; 235 | TestTargetID = 03B9B37920B7A2C000BEE366; 236 | }; 237 | 03B9B39C20B7A2C200BEE366 = { 238 | CreatedOnToolsVersion = 9.3; 239 | TestTargetID = 03B9B37920B7A2C000BEE366; 240 | }; 241 | }; 242 | }; 243 | buildConfigurationList = 03B9B37520B7A2C000BEE366 /* Build configuration list for PBXProject "YBArchiveUtilDemo" */; 244 | compatibilityVersion = "Xcode 9.3"; 245 | developmentRegion = en; 246 | hasScannedForEncodings = 0; 247 | knownRegions = ( 248 | en, 249 | Base, 250 | ); 251 | mainGroup = 03B9B37120B7A2C000BEE366; 252 | productRefGroup = 03B9B37B20B7A2C000BEE366 /* Products */; 253 | projectDirPath = ""; 254 | projectRoot = ""; 255 | targets = ( 256 | 03B9B37920B7A2C000BEE366 /* YBArchiveUtilDemo */, 257 | 03B9B39120B7A2C200BEE366 /* YBArchiveUtilDemoTests */, 258 | 03B9B39C20B7A2C200BEE366 /* YBArchiveUtilDemoUITests */, 259 | ); 260 | }; 261 | /* End PBXProject section */ 262 | 263 | /* Begin PBXResourcesBuildPhase section */ 264 | 03B9B37820B7A2C000BEE366 /* Resources */ = { 265 | isa = PBXResourcesBuildPhase; 266 | buildActionMask = 2147483647; 267 | files = ( 268 | 03B9B38A20B7A2C200BEE366 /* LaunchScreen.storyboard in Resources */, 269 | 03B9B38720B7A2C200BEE366 /* Assets.xcassets in Resources */, 270 | 03B9B38520B7A2C000BEE366 /* Main.storyboard in Resources */, 271 | ); 272 | runOnlyForDeploymentPostprocessing = 0; 273 | }; 274 | 03B9B39020B7A2C200BEE366 /* Resources */ = { 275 | isa = PBXResourcesBuildPhase; 276 | buildActionMask = 2147483647; 277 | files = ( 278 | ); 279 | runOnlyForDeploymentPostprocessing = 0; 280 | }; 281 | 03B9B39B20B7A2C200BEE366 /* Resources */ = { 282 | isa = PBXResourcesBuildPhase; 283 | buildActionMask = 2147483647; 284 | files = ( 285 | ); 286 | runOnlyForDeploymentPostprocessing = 0; 287 | }; 288 | /* End PBXResourcesBuildPhase section */ 289 | 290 | /* Begin PBXSourcesBuildPhase section */ 291 | 03B9B37620B7A2C000BEE366 /* Sources */ = { 292 | isa = PBXSourcesBuildPhase; 293 | buildActionMask = 2147483647; 294 | files = ( 295 | 03B9B3B920B7C78E00BEE366 /* Person.m in Sources */, 296 | 03B9B3B520B7A3B400BEE366 /* YBArchiveUtil.m in Sources */, 297 | 03B9B3BC20B7D3C400BEE366 /* YBArchiveTool.m in Sources */, 298 | 03B9B38220B7A2C000BEE366 /* ViewController.m in Sources */, 299 | 03B9B38D20B7A2C200BEE366 /* main.m in Sources */, 300 | 03B9B3B220B7A32800BEE366 /* YBAutoArchive.m in Sources */, 301 | 03B9B37F20B7A2C000BEE366 /* AppDelegate.m in Sources */, 302 | ); 303 | runOnlyForDeploymentPostprocessing = 0; 304 | }; 305 | 03B9B38E20B7A2C200BEE366 /* Sources */ = { 306 | isa = PBXSourcesBuildPhase; 307 | buildActionMask = 2147483647; 308 | files = ( 309 | 03B9B39720B7A2C200BEE366 /* YBArchiveUtilDemoTests.m in Sources */, 310 | ); 311 | runOnlyForDeploymentPostprocessing = 0; 312 | }; 313 | 03B9B39920B7A2C200BEE366 /* Sources */ = { 314 | isa = PBXSourcesBuildPhase; 315 | buildActionMask = 2147483647; 316 | files = ( 317 | 03B9B3A220B7A2C200BEE366 /* YBArchiveUtilDemoUITests.m in Sources */, 318 | ); 319 | runOnlyForDeploymentPostprocessing = 0; 320 | }; 321 | /* End PBXSourcesBuildPhase section */ 322 | 323 | /* Begin PBXTargetDependency section */ 324 | 03B9B39420B7A2C200BEE366 /* PBXTargetDependency */ = { 325 | isa = PBXTargetDependency; 326 | target = 03B9B37920B7A2C000BEE366 /* YBArchiveUtilDemo */; 327 | targetProxy = 03B9B39320B7A2C200BEE366 /* PBXContainerItemProxy */; 328 | }; 329 | 03B9B39F20B7A2C200BEE366 /* PBXTargetDependency */ = { 330 | isa = PBXTargetDependency; 331 | target = 03B9B37920B7A2C000BEE366 /* YBArchiveUtilDemo */; 332 | targetProxy = 03B9B39E20B7A2C200BEE366 /* PBXContainerItemProxy */; 333 | }; 334 | /* End PBXTargetDependency section */ 335 | 336 | /* Begin PBXVariantGroup section */ 337 | 03B9B38320B7A2C000BEE366 /* Main.storyboard */ = { 338 | isa = PBXVariantGroup; 339 | children = ( 340 | 03B9B38420B7A2C000BEE366 /* Base */, 341 | ); 342 | name = Main.storyboard; 343 | sourceTree = ""; 344 | }; 345 | 03B9B38820B7A2C200BEE366 /* LaunchScreen.storyboard */ = { 346 | isa = PBXVariantGroup; 347 | children = ( 348 | 03B9B38920B7A2C200BEE366 /* Base */, 349 | ); 350 | name = LaunchScreen.storyboard; 351 | sourceTree = ""; 352 | }; 353 | /* End PBXVariantGroup section */ 354 | 355 | /* Begin XCBuildConfiguration section */ 356 | 03B9B3A420B7A2C200BEE366 /* Debug */ = { 357 | isa = XCBuildConfiguration; 358 | buildSettings = { 359 | ALWAYS_SEARCH_USER_PATHS = NO; 360 | CLANG_ANALYZER_NONNULL = YES; 361 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 362 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 363 | CLANG_CXX_LIBRARY = "libc++"; 364 | CLANG_ENABLE_MODULES = YES; 365 | CLANG_ENABLE_OBJC_ARC = YES; 366 | CLANG_ENABLE_OBJC_WEAK = YES; 367 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 368 | CLANG_WARN_BOOL_CONVERSION = YES; 369 | CLANG_WARN_COMMA = YES; 370 | CLANG_WARN_CONSTANT_CONVERSION = YES; 371 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 372 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 373 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 374 | CLANG_WARN_EMPTY_BODY = YES; 375 | CLANG_WARN_ENUM_CONVERSION = YES; 376 | CLANG_WARN_INFINITE_RECURSION = YES; 377 | CLANG_WARN_INT_CONVERSION = YES; 378 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 379 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 380 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 381 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 382 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 383 | CLANG_WARN_STRICT_PROTOTYPES = YES; 384 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 385 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 386 | CLANG_WARN_UNREACHABLE_CODE = YES; 387 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 388 | CODE_SIGN_IDENTITY = "iPhone Developer"; 389 | COPY_PHASE_STRIP = NO; 390 | DEBUG_INFORMATION_FORMAT = dwarf; 391 | ENABLE_STRICT_OBJC_MSGSEND = YES; 392 | ENABLE_TESTABILITY = YES; 393 | GCC_C_LANGUAGE_STANDARD = gnu11; 394 | GCC_DYNAMIC_NO_PIC = NO; 395 | GCC_NO_COMMON_BLOCKS = YES; 396 | GCC_OPTIMIZATION_LEVEL = 0; 397 | GCC_PREPROCESSOR_DEFINITIONS = ( 398 | "DEBUG=1", 399 | "$(inherited)", 400 | ); 401 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 402 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 403 | GCC_WARN_UNDECLARED_SELECTOR = YES; 404 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 405 | GCC_WARN_UNUSED_FUNCTION = YES; 406 | GCC_WARN_UNUSED_VARIABLE = YES; 407 | IPHONEOS_DEPLOYMENT_TARGET = 11.3; 408 | MTL_ENABLE_DEBUG_INFO = YES; 409 | ONLY_ACTIVE_ARCH = YES; 410 | SDKROOT = iphoneos; 411 | }; 412 | name = Debug; 413 | }; 414 | 03B9B3A520B7A2C200BEE366 /* Release */ = { 415 | isa = XCBuildConfiguration; 416 | buildSettings = { 417 | ALWAYS_SEARCH_USER_PATHS = NO; 418 | CLANG_ANALYZER_NONNULL = YES; 419 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 420 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 421 | CLANG_CXX_LIBRARY = "libc++"; 422 | CLANG_ENABLE_MODULES = YES; 423 | CLANG_ENABLE_OBJC_ARC = YES; 424 | CLANG_ENABLE_OBJC_WEAK = YES; 425 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 426 | CLANG_WARN_BOOL_CONVERSION = YES; 427 | CLANG_WARN_COMMA = YES; 428 | CLANG_WARN_CONSTANT_CONVERSION = YES; 429 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 430 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 431 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 432 | CLANG_WARN_EMPTY_BODY = YES; 433 | CLANG_WARN_ENUM_CONVERSION = YES; 434 | CLANG_WARN_INFINITE_RECURSION = YES; 435 | CLANG_WARN_INT_CONVERSION = YES; 436 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 437 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 438 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 439 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 440 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 441 | CLANG_WARN_STRICT_PROTOTYPES = YES; 442 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 443 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 444 | CLANG_WARN_UNREACHABLE_CODE = YES; 445 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 446 | CODE_SIGN_IDENTITY = "iPhone Developer"; 447 | COPY_PHASE_STRIP = NO; 448 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 449 | ENABLE_NS_ASSERTIONS = NO; 450 | ENABLE_STRICT_OBJC_MSGSEND = YES; 451 | GCC_C_LANGUAGE_STANDARD = gnu11; 452 | GCC_NO_COMMON_BLOCKS = YES; 453 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 454 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 455 | GCC_WARN_UNDECLARED_SELECTOR = YES; 456 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 457 | GCC_WARN_UNUSED_FUNCTION = YES; 458 | GCC_WARN_UNUSED_VARIABLE = YES; 459 | IPHONEOS_DEPLOYMENT_TARGET = 11.3; 460 | MTL_ENABLE_DEBUG_INFO = NO; 461 | SDKROOT = iphoneos; 462 | VALIDATE_PRODUCT = YES; 463 | }; 464 | name = Release; 465 | }; 466 | 03B9B3A720B7A2C200BEE366 /* Debug */ = { 467 | isa = XCBuildConfiguration; 468 | buildSettings = { 469 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 470 | CODE_SIGN_STYLE = Automatic; 471 | DEVELOPMENT_TEAM = 2R36ULMSTJ; 472 | INFOPLIST_FILE = YBArchiveUtilDemo/Info.plist; 473 | LD_RUNPATH_SEARCH_PATHS = ( 474 | "$(inherited)", 475 | "@executable_path/Frameworks", 476 | ); 477 | PRODUCT_BUNDLE_IDENTIFIER = top.wangyingbo.www.YBArchiveUtilDemo; 478 | PRODUCT_NAME = "$(TARGET_NAME)"; 479 | TARGETED_DEVICE_FAMILY = "1,2"; 480 | }; 481 | name = Debug; 482 | }; 483 | 03B9B3A820B7A2C200BEE366 /* Release */ = { 484 | isa = XCBuildConfiguration; 485 | buildSettings = { 486 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 487 | CODE_SIGN_STYLE = Automatic; 488 | DEVELOPMENT_TEAM = 2R36ULMSTJ; 489 | INFOPLIST_FILE = YBArchiveUtilDemo/Info.plist; 490 | LD_RUNPATH_SEARCH_PATHS = ( 491 | "$(inherited)", 492 | "@executable_path/Frameworks", 493 | ); 494 | PRODUCT_BUNDLE_IDENTIFIER = top.wangyingbo.www.YBArchiveUtilDemo; 495 | PRODUCT_NAME = "$(TARGET_NAME)"; 496 | TARGETED_DEVICE_FAMILY = "1,2"; 497 | }; 498 | name = Release; 499 | }; 500 | 03B9B3AA20B7A2C200BEE366 /* Debug */ = { 501 | isa = XCBuildConfiguration; 502 | buildSettings = { 503 | BUNDLE_LOADER = "$(TEST_HOST)"; 504 | CODE_SIGN_STYLE = Automatic; 505 | DEVELOPMENT_TEAM = 2T9CHG78WE; 506 | INFOPLIST_FILE = YBArchiveUtilDemoTests/Info.plist; 507 | LD_RUNPATH_SEARCH_PATHS = ( 508 | "$(inherited)", 509 | "@executable_path/Frameworks", 510 | "@loader_path/Frameworks", 511 | ); 512 | PRODUCT_BUNDLE_IDENTIFIER = top.wangyingbo.www.YBArchiveUtilDemoTests; 513 | PRODUCT_NAME = "$(TARGET_NAME)"; 514 | TARGETED_DEVICE_FAMILY = "1,2"; 515 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/YBArchiveUtilDemo.app/YBArchiveUtilDemo"; 516 | }; 517 | name = Debug; 518 | }; 519 | 03B9B3AB20B7A2C200BEE366 /* Release */ = { 520 | isa = XCBuildConfiguration; 521 | buildSettings = { 522 | BUNDLE_LOADER = "$(TEST_HOST)"; 523 | CODE_SIGN_STYLE = Automatic; 524 | DEVELOPMENT_TEAM = 2T9CHG78WE; 525 | INFOPLIST_FILE = YBArchiveUtilDemoTests/Info.plist; 526 | LD_RUNPATH_SEARCH_PATHS = ( 527 | "$(inherited)", 528 | "@executable_path/Frameworks", 529 | "@loader_path/Frameworks", 530 | ); 531 | PRODUCT_BUNDLE_IDENTIFIER = top.wangyingbo.www.YBArchiveUtilDemoTests; 532 | PRODUCT_NAME = "$(TARGET_NAME)"; 533 | TARGETED_DEVICE_FAMILY = "1,2"; 534 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/YBArchiveUtilDemo.app/YBArchiveUtilDemo"; 535 | }; 536 | name = Release; 537 | }; 538 | 03B9B3AD20B7A2C200BEE366 /* Debug */ = { 539 | isa = XCBuildConfiguration; 540 | buildSettings = { 541 | CODE_SIGN_STYLE = Automatic; 542 | DEVELOPMENT_TEAM = 2T9CHG78WE; 543 | INFOPLIST_FILE = YBArchiveUtilDemoUITests/Info.plist; 544 | LD_RUNPATH_SEARCH_PATHS = ( 545 | "$(inherited)", 546 | "@executable_path/Frameworks", 547 | "@loader_path/Frameworks", 548 | ); 549 | PRODUCT_BUNDLE_IDENTIFIER = top.wangyingbo.www.YBArchiveUtilDemoUITests; 550 | PRODUCT_NAME = "$(TARGET_NAME)"; 551 | TARGETED_DEVICE_FAMILY = "1,2"; 552 | TEST_TARGET_NAME = YBArchiveUtilDemo; 553 | }; 554 | name = Debug; 555 | }; 556 | 03B9B3AE20B7A2C200BEE366 /* Release */ = { 557 | isa = XCBuildConfiguration; 558 | buildSettings = { 559 | CODE_SIGN_STYLE = Automatic; 560 | DEVELOPMENT_TEAM = 2T9CHG78WE; 561 | INFOPLIST_FILE = YBArchiveUtilDemoUITests/Info.plist; 562 | LD_RUNPATH_SEARCH_PATHS = ( 563 | "$(inherited)", 564 | "@executable_path/Frameworks", 565 | "@loader_path/Frameworks", 566 | ); 567 | PRODUCT_BUNDLE_IDENTIFIER = top.wangyingbo.www.YBArchiveUtilDemoUITests; 568 | PRODUCT_NAME = "$(TARGET_NAME)"; 569 | TARGETED_DEVICE_FAMILY = "1,2"; 570 | TEST_TARGET_NAME = YBArchiveUtilDemo; 571 | }; 572 | name = Release; 573 | }; 574 | /* End XCBuildConfiguration section */ 575 | 576 | /* Begin XCConfigurationList section */ 577 | 03B9B37520B7A2C000BEE366 /* Build configuration list for PBXProject "YBArchiveUtilDemo" */ = { 578 | isa = XCConfigurationList; 579 | buildConfigurations = ( 580 | 03B9B3A420B7A2C200BEE366 /* Debug */, 581 | 03B9B3A520B7A2C200BEE366 /* Release */, 582 | ); 583 | defaultConfigurationIsVisible = 0; 584 | defaultConfigurationName = Release; 585 | }; 586 | 03B9B3A620B7A2C200BEE366 /* Build configuration list for PBXNativeTarget "YBArchiveUtilDemo" */ = { 587 | isa = XCConfigurationList; 588 | buildConfigurations = ( 589 | 03B9B3A720B7A2C200BEE366 /* Debug */, 590 | 03B9B3A820B7A2C200BEE366 /* Release */, 591 | ); 592 | defaultConfigurationIsVisible = 0; 593 | defaultConfigurationName = Release; 594 | }; 595 | 03B9B3A920B7A2C200BEE366 /* Build configuration list for PBXNativeTarget "YBArchiveUtilDemoTests" */ = { 596 | isa = XCConfigurationList; 597 | buildConfigurations = ( 598 | 03B9B3AA20B7A2C200BEE366 /* Debug */, 599 | 03B9B3AB20B7A2C200BEE366 /* Release */, 600 | ); 601 | defaultConfigurationIsVisible = 0; 602 | defaultConfigurationName = Release; 603 | }; 604 | 03B9B3AC20B7A2C200BEE366 /* Build configuration list for PBXNativeTarget "YBArchiveUtilDemoUITests" */ = { 605 | isa = XCConfigurationList; 606 | buildConfigurations = ( 607 | 03B9B3AD20B7A2C200BEE366 /* Debug */, 608 | 03B9B3AE20B7A2C200BEE366 /* Release */, 609 | ); 610 | defaultConfigurationIsVisible = 0; 611 | defaultConfigurationName = Release; 612 | }; 613 | /* End XCConfigurationList section */ 614 | }; 615 | rootObject = 03B9B37220B7A2C000BEE366 /* Project object */; 616 | } 617 | -------------------------------------------------------------------------------- /YBArchiveUtilDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /YBArchiveUtilDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /YBArchiveUtilDemo.xcodeproj/project.xcworkspace/xcuserdata/wangyingbo.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangyingbo/YBArchiveUtilDemo/9d67ed10e3968e5f27cb61cb0d88953fb996ce59/YBArchiveUtilDemo.xcodeproj/project.xcworkspace/xcuserdata/wangyingbo.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /YBArchiveUtilDemo.xcodeproj/xcuserdata/wangyingbo.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /YBArchiveUtilDemo.xcodeproj/xcuserdata/wangyingbo.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | YBArchiveUtilDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /YBArchiveUtilDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // YBArchiveUtilDemo 4 | // 5 | // Created by 王迎博 on 2018/5/25. 6 | // Copyright © 2018年 王颖博. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /YBArchiveUtilDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // YBArchiveUtilDemo 4 | // 5 | // Created by 王迎博 on 2018/5/25. 6 | // Copyright © 2018年 王颖博. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /YBArchiveUtilDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /YBArchiveUtilDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /YBArchiveUtilDemo/Base.lproj/LaunchScreen.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 | -------------------------------------------------------------------------------- /YBArchiveUtilDemo/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 | -------------------------------------------------------------------------------- /YBArchiveUtilDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /YBArchiveUtilDemo/Person.h: -------------------------------------------------------------------------------- 1 | // 2 | // Person.h 3 | // YBArchiveUtilDemo 4 | // 5 | // Created by 王迎博 on 2018/5/25. 6 | // Copyright © 2018年 王颖博. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface Child : NSObject 12 | @property (nonatomic, strong) NSString *nickName; 13 | @property (nonatomic, strong) NSString *school; 14 | @end 15 | 16 | 17 | @interface Person : NSObject 18 | 19 | @property (nonatomic, copy) NSString *name; 20 | @property (nonatomic, assign)int age; 21 | @property (nonatomic, assign) NSInteger ID; 22 | @property (nonatomic, assign) BOOL isShow; 23 | @property (nonatomic, strong) NSNumber *tagNumber; 24 | @property (nonatomic, strong) Child *child; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /YBArchiveUtilDemo/Person.m: -------------------------------------------------------------------------------- 1 | // 2 | // Person.m 3 | // YBArchiveUtilDemo 4 | // 5 | // Created by 王迎博 on 2018/5/25. 6 | // Copyright © 2018年 王颖博. All rights reserved. 7 | // 8 | 9 | #import "Person.h" 10 | #import "YBArchiveUtilHeader.h" 11 | 12 | @implementation Child 13 | YB_IMPLEMENTATION_CODE_WITH_CODER 14 | @end 15 | 16 | 17 | @implementation Person 18 | 19 | YB_IMPLEMENTATION_CODE_WITH_CODER 20 | 21 | - (NSString*)description 22 | { 23 | [NSString stringWithFormat:@"%@",[self class]]; 24 | 25 | return [NSString stringWithFormat:@"-------姓名=%@-------年龄=%d-------ID=%ld-------boo值=%@-------number型=%@-------child昵称=%@-------child学校=%@",self.name,self.age,(long)self.ID,(self.isShow?@"yes":@"no"),self.tagNumber,self.child.nickName,self.child.school]; 26 | } 27 | @end 28 | -------------------------------------------------------------------------------- /YBArchiveUtilDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // YBArchiveUtilDemo 4 | // 5 | // Created by 王迎博 on 2018/5/25. 6 | // Copyright © 2018年 王颖博. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /YBArchiveUtilDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // YBArchiveUtilDemo 4 | // 5 | // Created by 王迎博 on 2018/5/25. 6 | // Copyright © 2018年 王颖博. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "Person.h" 11 | #import "YBArchiveUtilHeader.h" 12 | 13 | @interface ViewController () 14 | 15 | @end 16 | 17 | 18 | @implementation ViewController 19 | 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | 24 | UIButton * btn1 = [UIButton buttonWithType:UIButtonTypeCustom]; 25 | btn1.backgroundColor = [UIColor redColor]; 26 | btn1.frame = CGRectMake(100, 100,150, 40); 27 | btn1.center = CGPointMake(self.view.center.x, btn1.center.y); 28 | [btn1 setTitle:@"归档单个对象" forState:UIControlStateNormal]; 29 | [btn1 addTarget:self action:@selector(archiverSingle) forControlEvents:UIControlEventTouchUpInside]; 30 | [self.view addSubview:btn1]; 31 | 32 | UIButton * btn2 = [UIButton buttonWithType:UIButtonTypeCustom]; 33 | btn2.backgroundColor = [UIColor orangeColor]; 34 | btn2.frame = CGRectMake(100, 150, 150, 40); 35 | btn2.center = CGPointMake(self.view.center.x, btn2.center.y); 36 | [btn2 setTitle:@"解档单个对象" forState:UIControlStateNormal]; 37 | [btn2 addTarget:self action:@selector(unarchiverSingle) forControlEvents:UIControlEventTouchUpInside]; 38 | [self.view addSubview:btn2]; 39 | 40 | 41 | UIButton * btn3 = [UIButton buttonWithType:UIButtonTypeCustom]; 42 | btn3.backgroundColor = [UIColor purpleColor]; 43 | btn3.frame = CGRectMake(100, 200, 150, 40); 44 | btn3.center = CGPointMake(self.view.center.x, btn3.center.y); 45 | [btn3 setTitle:@"归档多个对象" forState:UIControlStateNormal]; 46 | [btn3 addTarget:self action:@selector(archiverMutable) forControlEvents:UIControlEventTouchUpInside]; 47 | [self.view addSubview:btn3]; 48 | 49 | UIButton * btn4 = [UIButton buttonWithType:UIButtonTypeCustom]; 50 | btn4.backgroundColor = [UIColor blueColor]; 51 | btn4.frame = CGRectMake(100, 250, 150, 40); 52 | btn4.center = CGPointMake(self.view.center.x, btn4.center.y); 53 | [btn4 setTitle:@"解档多个对象" forState:UIControlStateNormal]; 54 | [btn4 addTarget:self action:@selector(unarchiverMutable) forControlEvents:UIControlEventTouchUpInside]; 55 | [self.view addSubview:btn4]; 56 | 57 | //YBDPRINT(@"test the print"); 58 | } 59 | 60 | #pragma mark - private 61 | - (void)archiverSingle 62 | { 63 | Person *p = [[Person alloc]init]; 64 | p.name = @"张三"; 65 | p.age = 20; 66 | p.ID = 0; 67 | p.isShow = YES; 68 | p.tagNumber = @5; 69 | 70 | Child *child = [[Child alloc]init]; 71 | child.nickName = @"狗蛋儿"; 72 | child.school = @"春田花花幼儿园"; 73 | p.child = child; 74 | 75 | BOOL success = [YBArchiveUtil saveObject:p withFilePathName:@"single"]; 76 | 77 | if (success) { 78 | NSLog(@"归档单个对象成功"); 79 | } else { 80 | NSLog(@"归档单个对象失败"); 81 | } 82 | 83 | } 84 | 85 | - (void)unarchiverSingle 86 | { 87 | Person * p = [YBArchiveUtil getObjectWithFilePathName:@"single"]; 88 | NSLog(@"-------姓名=%@-------年龄=%d-------ID=%ld-------boo值=%@-------number型=%@-------child昵称=%@-------child学校=%@",p.name,p.age,(long)p.ID,(p.isShow?@"yes":@"no"),p.tagNumber,p.child.nickName,p.child.school); 89 | } 90 | 91 | - (void)archiverMutable 92 | { 93 | NSMutableArray * data = [NSMutableArray array]; 94 | 95 | for (int i = 0; i<10; i++) 96 | { 97 | Person * p = [[Person alloc]init]; 98 | p.name = [NSString stringWithFormat:@"李四%d",i]; 99 | p.age = 10+i; 100 | p.ID = i; 101 | 102 | Child *child = [[Child alloc] init]; 103 | child.nickName = @"二妞儿"; 104 | child.school = @"霍格沃兹"; 105 | p.child = child; 106 | 107 | [data addObject:p]; 108 | } 109 | 110 | BOOL success = [YBArchiveUtil saveObjects:data forFlag:@"flag1" withFilePathName:@"multi"]; 111 | 112 | if (success) { 113 | NSLog(@"归档多个对象成功"); 114 | } else { 115 | NSLog(@"归档多个对象失败"); 116 | } 117 | } 118 | 119 | - (void)unarchiverMutable 120 | { 121 | NSArray * data =[YBArchiveUtil getObjectsForFlag:@"flag1" withFilePathName:@"multi"]; 122 | 123 | NSLog(@"---------------%@",data); 124 | 125 | Person *p = [data lastObject]; 126 | if (p) { 127 | NSLog(@"-------姓名=%@-------年龄=%d-------ID=%ld-------boo值=%@-------number型=%@-------child昵称=%@-------child学校=%@",p.name,p.age,(long)p.ID,(p.isShow?@"yes":@"no"),p.tagNumber,p.child.nickName,p.child.school); 128 | } 129 | 130 | } 131 | @end 132 | -------------------------------------------------------------------------------- /YBArchiveUtilDemo/YBArchiveUtil/YBArchiveTool.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBArchiveTool.h 3 | // YBArchiveUtilDemo 4 | // 5 | // Created by 王迎博 on 2018/5/25. 6 | // Copyright © 2018年 王颖博. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | //#ifdef DEBUG 13 | //#define DLog(...) NSLog(@"%s [line %d] %@", __PRETTY_FUNCTION__, __LINE__, [NSString stringWithFormat:__VA_ARGS__]) 14 | //#else 15 | //#define DLog(...) 16 | //#endif 17 | 18 | 19 | #if defined(DEBUG) 20 | #define YBDPRINT(xx, ...) NSLog(@"%s(%d行): " xx, __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__) 21 | #else 22 | #define YBDPRINT(xx, ...) ((void)0) 23 | #endif // #if defined(DEBUG) 24 | 25 | 26 | @interface YBArchiveTool : NSObject 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /YBArchiveUtilDemo/YBArchiveUtil/YBArchiveTool.m: -------------------------------------------------------------------------------- 1 | // 2 | // YBArchiveTool.m 3 | // YBArchiveUtilDemo 4 | // 5 | // Created by 王迎博 on 2018/5/25. 6 | // Copyright © 2018年 王颖博. All rights reserved. 7 | // 8 | 9 | #import "YBArchiveTool.h" 10 | 11 | 12 | BOOL YBDebugAssertionsShouldBreak = YES; 13 | #if defined(DEBUG) 14 | #import 15 | #import 16 | #import 17 | // From: http://developer.apple.com/mac/library/qa/qa2004/qa1361.html 18 | int YBIsInDebugger(void) { 19 | int mib[4]; 20 | struct kinfo_proc info; 21 | size_t size; 22 | info.kp_proc.p_flag = 0; 23 | mib[0] = CTL_KERN; 24 | mib[1] = KERN_PROC; 25 | mib[2] = KERN_PROC_PID; 26 | mib[3] = getpid(); 27 | size = sizeof(info); 28 | sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0); 29 | return (info.kp_proc.p_flag & P_TRACED) != 0; 30 | } 31 | #endif 32 | 33 | 34 | 35 | 36 | @implementation YBArchiveTool 37 | @end 38 | -------------------------------------------------------------------------------- /YBArchiveUtilDemo/YBArchiveUtil/YBArchiveUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // YBArchiveUtil.h 3 | // YBArchiveUtilDemo 4 | // 5 | // Created by 王迎博 on 2018/5/25. 6 | // Copyright © 2018年 王颖博. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface YBArchiveUtil : NSObject 12 | 13 | 14 | /** 15 | 指定默认保存数据的文件名,全局只用设置一次 16 | 17 | @param pathName 文件名 18 | */ 19 | + (void)setPlistPathName:(NSString*)pathName; 20 | 21 | /** 22 | 保存单个数据 23 | 24 | @param obj 实现了归档的对象 25 | @param filePathName 文件名,如果传值nil,则会保存在默认的defaultPathName里 26 | @return 保存状态 27 | */ 28 | + (BOOL)saveObject:(id)obj withFilePathName:(NSString *)filePathName; 29 | 30 | /** 31 | 取出单个数据 32 | 33 | @param filePathName 文件名,如果传值nil,则会在默认的defaultPathName里取 34 | @return 对象 35 | */ 36 | + (id)getObjectWithFilePathName:(NSString *)filePathName; 37 | 38 | /** 39 | 移除文件名下的对象 40 | 41 | @param filePathName 文件名,如果传值nil,则return 42 | @return 执行结果 43 | */ 44 | + (BOOL)removeObjectWithFilePathName:(NSString *)filePathName; 45 | 46 | /** 47 | 保存多个数据 48 | 49 | @param objs 多个数据数组 50 | @param flag flag description 51 | @param filePathName 文件名,如果传值nil,则会保存在默认的defaultPathName里 52 | @return 保存状态 53 | */ 54 | + (BOOL)saveObjects:(NSArray *)objs forFlag:(NSString*)flag withFilePathName:(NSString *)filePathName; 55 | 56 | /** 57 | 取多个数据 58 | 59 | @param flag flag description 60 | @param filePathName 文件名,如果传值nil,则会在默认的defaultPathName里取 61 | @return 多个数据的数组 62 | */ 63 | + (NSArray *)getObjectsForFlag:(NSString*)flag withFilePathName:(NSString *)filePathName; 64 | 65 | /** 66 | 检查是否遵守了NSCoding协议,是否实现了归档方法 67 | 68 | @param obj 待归档解档的对象 69 | @return 检查结果状态 70 | */ 71 | + (BOOL)checkEncodeWithCoder:(id)obj; 72 | @end 73 | -------------------------------------------------------------------------------- /YBArchiveUtilDemo/YBArchiveUtil/YBArchiveUtil.m: -------------------------------------------------------------------------------- 1 | // 2 | // YBArchiveUtil.m 3 | // YBArchiveUtilDemo 4 | // 5 | // Created by 王迎博 on 2018/5/25. 6 | // Copyright © 2018年 王颖博. All rights reserved. 7 | // 8 | 9 | #import "YBArchiveUtil.h" 10 | #import "YBArchiveUtilHeader.h" 11 | 12 | 13 | #define DEFAULT_STORE_PATH_KEY @"kYBStorePathKey" 14 | #define DEFAULT_STORE_PATH_NAME @"kYBDefaultPathName" 15 | 16 | @implementation YBArchiveUtil 17 | 18 | + (void)setPlistPathName:(NSString *)pathName { 19 | NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults]; 20 | NSString *defaultPathName = [defaults objectForKey:DEFAULT_STORE_PATH_KEY]; 21 | if (defaultPathName) { return; } 22 | 23 | [defaults setObject:(pathName?pathName:DEFAULT_STORE_PATH_NAME) forKey:DEFAULT_STORE_PATH_KEY]; 24 | [defaults synchronize]; 25 | } 26 | 27 | + (BOOL)saveObject:(id)obj withFilePathName:(NSString *)filePathName { 28 | //判断obj里是否实现了归档方法 29 | if (![self checkEncodeWithCoder:obj]) { 30 | YBDPRINT(@"%@ 没有实现encodeWithCoder方法",obj); 31 | YBDASSERT([self checkEncodeWithCoder:obj]); 32 | return NO; 33 | } 34 | 35 | return [NSKeyedArchiver archiveRootObject:obj toFile:[self getFilePathWithFilePathName:filePathName]]; 36 | } 37 | 38 | + (id)getObjectWithFilePathName:(NSString *)filePathName { 39 | return [NSKeyedUnarchiver unarchiveObjectWithFile:[self getFilePathWithFilePathName:filePathName]]; 40 | } 41 | 42 | + (BOOL)removeObjectWithFilePathName:(NSString *)filePathName { 43 | if (!filePathName) {//没有路径名时 44 | YBDASSERT(filePathName); 45 | return NO; 46 | } 47 | 48 | NSFileManager * fileManager = [NSFileManager defaultManager]; 49 | BOOL exist = [fileManager fileExistsAtPath:[self getFilePathWithFilePathName:filePathName]]; 50 | if (exist) { 51 | exist = [fileManager removeItemAtPath:[self getFilePathWithFilePathName:filePathName] error:nil]; 52 | } 53 | 54 | return exist; 55 | } 56 | 57 | + (BOOL)saveObjects:(NSArray *)objs forFlag:(NSString*)flag withFilePathName:(NSString *)filePathName 58 | { 59 | if (!objs || objs.count<1) { return NO; } 60 | 61 | //判断objs每个数据里是否实现了归档方法 62 | for (id obj in objs) { 63 | if (![self checkEncodeWithCoder:obj]) { 64 | YBDPRINT(@"%@ 没有实现encodeWithCoder方法",obj); 65 | YBDASSERT([self checkEncodeWithCoder:obj]); 66 | return NO; 67 | } 68 | } 69 | 70 | NSMutableData * data = [[NSMutableData alloc]init]; 71 | NSKeyedArchiver * archiver = [[NSKeyedArchiver alloc]initForWritingWithMutableData:data]; 72 | [archiver encodeObject:objs forKey:flag]; 73 | [archiver finishEncoding]; 74 | 75 | BOOL success = [data writeToFile:[self getFilePathWithFilePathName:filePathName] atomically:YES]; 76 | 77 | return success; 78 | } 79 | 80 | + (NSArray *)getObjectsForFlag:(NSString*)flag withFilePathName:(NSString *)filePathName 81 | { 82 | NSData *data = [[NSData alloc] initWithContentsOfFile:[self getFilePathWithFilePathName:filePathName]]; 83 | 84 | NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data]; 85 | NSArray * array = [unarchiver decodeObjectForKey:flag]; 86 | 87 | return array; 88 | } 89 | 90 | /** 91 | 检查是否遵守了NSCoding协议,是否实现了归档方法 92 | 93 | @param obj 待归档解档的对象 94 | @return 检查结果状态 95 | */ 96 | + (BOOL)checkEncodeWithCoder:(id)obj { 97 | // && [obj conformsToProtocol:@protocol(NSCoding)] 98 | return ([obj respondsToSelector:@selector(encodeWithCoder:)]); 99 | } 100 | 101 | /** 102 | 根据文件名取回路径 103 | 104 | @param filePathName 文件名 105 | @return 路径 106 | */ 107 | + (NSString*)getFilePathWithFilePathName:(NSString *)filePathName 108 | { 109 | NSString *path = @""; 110 | NSArray *documentsPathArr = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 111 | NSString *cache = [documentsPathArr firstObject]; 112 | 113 | if (filePathName && filePathName.length>0) { 114 | path = [NSString stringWithFormat:@"%@/%@.plist",cache,filePathName]; 115 | }else { 116 | NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults]; 117 | NSString *pathName = [defaults valueForKey:DEFAULT_STORE_PATH_KEY]; 118 | 119 | if (pathName) { 120 | path = [NSString stringWithFormat:@"%@/%@.plist",cache,pathName]; 121 | }else { 122 | [defaults setObject:DEFAULT_STORE_PATH_NAME forKey:DEFAULT_STORE_PATH_KEY]; 123 | path = [NSString stringWithFormat:@"%@/%@.plist",cache,DEFAULT_STORE_PATH_NAME]; 124 | } 125 | } 126 | 127 | return path; 128 | } 129 | 130 | @end 131 | -------------------------------------------------------------------------------- /YBArchiveUtilDemo/YBArchiveUtil/YBArchiveUtilHeader.h: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // YBArchiveUtilHeader.h 4 | // YBArchiveUtilDemo 5 | // 6 | // Created by 王迎博 on 2018/5/25. 7 | // Copyright © 2018年 王颖博. All rights reserved. 8 | // 9 | 10 | #ifndef YBArchiveUtilHeader_h 11 | #define YBArchiveUtilHeader_h 12 | 13 | #pragma mark - 头文件引用 14 | #import 15 | #import "YBArchiveUtil.h" 16 | #import "YBAutoArchive.h" 17 | #import "YBArchiveTool.h" 18 | #import 19 | 20 | #pragma mark - 实现归档解档的宏 21 | /**实现归档解档的宏*/ 22 | #define YB_IMPLEMENTATION_CODE_WITH_CODER \ 23 | - (void)encodeWithCoder:(NSCoder *)aCoder { \ 24 | NSArray * properNames = [self properNames]; \ 25 | for (NSString * properName in properNames) { \ 26 | id value = [self valueForKey:properName]; \ 27 | if (value && properName) { \ 28 | [aCoder encodeObject:value forKey:properName]; \ 29 | } \ 30 | } \ 31 | } \ 32 | \ 33 | - (instancetype)initWithCoder:(NSCoder *)aDecoder { \ 34 | if (self = [super init]) { \ 35 | NSArray * properNames = [self properNames]; \ 36 | for (NSString * properName in properNames) { \ 37 | id value = [aDecoder decodeObjectForKey:properName]; \ 38 | if (value && properName) { \ 39 | [self setValue:value forKey:properName]; \ 40 | } \ 41 | } \ 42 | } \ 43 | return self; \ 44 | } \ 45 | \ 46 | - (NSArray*)properNames { \ 47 | unsigned int count; \ 48 | Ivar * ivarList = class_copyIvarList([self class], &count); \ 49 | NSMutableArray * propers = [NSMutableArray array]; \ 50 | for (int i = 0; i 11 | 12 | @interface YBAutoArchive : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /YBArchiveUtilDemo/YBArchiveUtil/YBAutoArchive.m: -------------------------------------------------------------------------------- 1 | // 2 | // YBAutoArchiveUtil.m 3 | // YBArchiveUtilDemo 4 | // 5 | // Created by 王迎博 on 2018/5/25. 6 | // Copyright © 2018年 王颖博. All rights reserved. 7 | // 8 | 9 | #import "YBAutoArchive.h" 10 | #import 11 | #import "YBArchiveUtil.h" 12 | #import "YBArchiveUtilHeader.h" 13 | 14 | @implementation YBAutoArchive 15 | 16 | //TODO:自动归档解档 17 | - (void)encodeWithCoder:(NSCoder *)aCoder { 18 | NSArray * properNames = [self properNames]; 19 | for (NSString * properName in properNames) { 20 | id value = [self valueForKey:properName]; 21 | //归档到文件中 22 | if (value && properName) { 23 | [aCoder encodeObject:value forKey:properName]; 24 | } 25 | } 26 | } 27 | 28 | - (instancetype)initWithCoder:(NSCoder *)aDecoder { 29 | if (self = [super init]) { 30 | NSArray * properNames = [self properNames]; 31 | for (NSString * properName in properNames) { 32 | id value = [aDecoder decodeObjectForKey:properName]; 33 | if (value && properName) { 34 | [self setValue:value forKey:properName]; 35 | } 36 | } 37 | } 38 | return self; 39 | } 40 | 41 | - (NSArray*)properNames { 42 | unsigned int count; 43 | Ivar * ivarList = class_copyIvarList([self class], &count); 44 | NSMutableArray * propers = [NSMutableArray array]; 45 | for (int i = 0; i 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /YBArchiveUtilDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /YBArchiveUtilDemoTests/YBArchiveUtilDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // YBArchiveUtilDemoTests.m 3 | // YBArchiveUtilDemoTests 4 | // 5 | // Created by 王迎博 on 2018/5/25. 6 | // Copyright © 2018年 王颖博. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface YBArchiveUtilDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation YBArchiveUtilDemoTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /YBArchiveUtilDemoUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /YBArchiveUtilDemoUITests/YBArchiveUtilDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // YBArchiveUtilDemoUITests.m 3 | // YBArchiveUtilDemoUITests 4 | // 5 | // Created by 王迎博 on 2018/5/25. 6 | // Copyright © 2018年 王颖博. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface YBArchiveUtilDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation YBArchiveUtilDemoUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangyingbo/YBArchiveUtilDemo/9d67ed10e3968e5f27cb61cb0d88953fb996ce59/screenshot.png --------------------------------------------------------------------------------