iOS安全的數據庫:ApolloDB
這是一個易于實現,用于在iOS App中安全得存儲數據的數據庫。
Installation
Simply copy the files to your project and add the frameworkJavaScriptCore.framework. Then import the fileApolloDB.hto the classes in which you will use ApolloDB.
Usage
It's simple, first of all to start a session, you must use the following code anywhere but before saving or getting an object from the DB.
BOOL passcodeIsValid = [[ApolloDB sharedManager]startSessionWithPasscode:@"yourDBPasscode"]; //Set a passcode for encrypting and decrypting your DB if (passcodeIsValid==false){ //The given passcode is different from the DB passcode }
Before starting the session, you can use any of the following methods for setting or getting an object from the DB. Remember that for saving custom classes as objects you must configure theencodeWithCoderandinitWithCodermethods of the class.
[[ApolloDB sharedManager]setObject:@"foo" forKey:@"bar"]; //Set an object for a key [[ApolloDB sharedManager]setObjects:@[@"foo", @"testing"] forKeys:@[@"bar", @"status"]]; //Set objects for the specified keys [[ApolloDB sharedManager]removeObjectForKey:@"bar"]; //Remove the object corresponding to the specified key [[ApolloDB sharedManager]removeObjectsForKeys:@[@"bar", @"status"]]; //Remove the objects corresponding to the specified keys [[ApolloDB sharedManager]objectForKey:@"bar"]; //Get the object corresponding to the specified key [[ApolloDB sharedManager]objectsForKeys:@[@"bar", @"status"]]; //Get the objects corresponding to the specified keys NSDictionary *myData = [[ApolloDB sharedManager]allData]; //Get all the DB data
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!