DB packets are parsed and extracted from a three-party framework downloaded from GitHub, typically in the form of arrays and dictionaries. DB's viewing tool is the parse DB plugin on Firefox, SQLite
Three-party framework for Fmdb
#import "ViewController.h"//1. Introduction of header file, need to introduce Libsqlite3 library #import "FMDB.h" #import "Word.h" @interface Viewcontroller () @end @implementation Viewcont roller-(void) viewdidload {[Super viewdidload]; 2. Create a Fmdatabase object and specify the file path fmdatabase *database = [fmdatabase databasewithpath:@ "/users/apple/desktop/japanese.db"]; 3. Open File if (![ Database Open] {NSLog (@ "Can not open File"); Return }//4. Execute query fmresultset *result = [Database executequery:@ "SELECT * from JP"]; Nsmutablearray *array = [Nsmutablearray array]; 5. Gets a row in the table while ([result next]) {//Nsmutabledictionary *dict = [Nsmutabledictionary dictionary]; Word *word = [[Word alloc] init]; Gets the data int rid = [result intforcolumn:@ "id"] according to the name (column name); NSLog (@ "RID:%d", RID); Word.rid = RID; [Dict setobject:[nsnumber Numberwithint:rid] forkey:@ "id"]; Get data int based on location RID1 = [result intforcolumnindex:0]; NSLog (@ "RID1:%d", RID1); NSString *kana = [result stringforcolumn:@ "kana"]; NSLog (@ "kana:%@", kana); [Dict setobject:kana forkey:@ "Kana"]; NSString *KANA1 = [result stringforcolumnindex:5]; NSLog (@ "KANA1:%@", KANA1); Word.kana = KANA1; [Array Addobject:word]; }//6. Close file [Database close]; NSLog (@ "-----------"); NSLog (@ "%@", array);}
This is the code in Word.h and WORD.M.
#import <Foundation/Foundation.h> @interface Word:nsobject@property (nonatomic, assign) Nsinteger RIDs; @property (nonatomic, copy) NSString *kana; @end
#import "Word.h" @implementation word-(NSString *) description{ return [NSString stringwithformat:@ "%@: RID:% d---Kana:%@ ", [Super description], _rid, _kana];} @end