IOS sqlite3 saves the array NSArray
Four Notes: 1. when creating a table, the declared field type is binary blobNSString * INEditorTableName = @ "create table In_Editor (picUrls blob not null)"; 2. insert an SQL statement and convert NSArray to NSData-type NSData * dataImageUrls = [NSKeyedArchiver archivedDataWithRootObject: model. imageUrls]; 3. [NSString stringWithFormat: @ "SQL"]; [_ db executeUpdate: @ "insert into In_Editor (picUrls) values (?); ", DataImageUrls]; 4. read data: NSArray * imageArr = [NSKeyedUnarchiver unarchiveObjectWithData: picUrls] // if you do not pay attention to the preceding items, the following error may occur: * Terminating app due to uncaught exception 'failed', reason: '-[_ NSCFData objectForKey:]: unrecognized selector sent to instance 0x6b46c80'
Note: NSArray and NSData are converted to NSData in binary format: NSData * data = [NSKeyedArchiver archivedDataWithRootObject: Array]; NSData is converted to NSArray: NSArray * array = [NSKeyedUnarchiver unarchiveObjectWithData: data]; Integer: value is signedinteger type, size can be 1, 2, 4, 6, 8 bytesREAL: floating point type TEXT: To UTF-8, character Type BLOB stored in UTF-16BEorUTF-16LE encoding: binary data