TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Hiroshi Hashiguchi.
NSKeyedArchiver/NSKeyedUnArchiver wrapper
[LKDocumentDirectoryArchiver archiveRootObject:userList
forKey:@"UserList"];
It executes like below functions.
// filename is equal to (Application Directory)/Documents/UserList.archive
[NSKeyedArchiver archiveRootObject:userList toFile:filename];
id userList = [LKDocumentDirectoryArchiver unarchiverObjectForKey:@"UserList"];
It executes like below functions.
id userList = [NSKeyedUnarchiver unarchiverObjectWithFile:filename];
If required default value case,
[LKDocumentDirectoryArchiver unarchiveObject:userList
forKey:@"UserList"
defaultObject:^id{
return @[].mutableCopy;
}];
Supports handling failure,
[LKDocumentDirectoryArchiver unarchiveObject:userList
forKey:@"UserList"
failure:^{
// do something
}];
You can use directory.
[LKDocumentDirectoryArchiver archiveRootObject:userList1
forKey:@"Support/01/UserList"];
// placed as bellow:
// (Application Directory)/Documents/Support/01/UserList.archive
The first "/" character will be removed. (e.g.) "/Sales/obj" => "Sales/obj"
You can remove an archive file.
[LKDOcumentDirectoryArchiver removeArchiverForKey:@"UserList"];
Check to exist an archiver file.
[LKDocumentDirectoryArchiver archiverExistsForKey:@"UserList"];
NSCachesDirectory is available too:
[LKCachesDirecotryArchiver archiveRootObject:userList toFile:filename];
Hiroshi Hashiguchi, [email protected]
LKArchiver is available under the MIT license. See the LICENSE file for more info.