Four Points of note: 1. When you create a table, the Declaration field type is binary blobnsstring *ineditortablename = @ "CREATE TABLE In_editor (Picurls blob not null)"; 2. Insert the SQL statement, Convert Nsarray to NSData type NSData *dataimageurls = [Nskeyedarchiver archiveddatawithrootobject:model.imageurls];3. cannot be used [ NSString stringWithFormat: @ "SQL"]; [_db executeupdate: @ "INSERT into In_editor (Picurls) values (?);", dataimageurls];4. Read data: Nsarray *imagearr = [Nskeyeduna Rchiver unarchiveobjectwithdata:picurls]//If you are not aware of the above points, the following error may appear: * Terminating app due to uncaught exception ' Nsinvalidargumentexception ', Reason: '-[__nscfdata objectforkey:]: Unrecognized selector sent to instance 0x6b46c80 '
Note: Nsarray and NSData convert the binary nsarray to NSData type: nsdata *data = [Nskeyedarchiver Archiveddatawithrootobject:array]; Convert NSData to Nsarray type: nsarray *array = [Nskeyedunarchiver Unarchiveobjectwithdata:data];integer: Value is Signedinteger type, Size can be 1,2,3,4,6,8bytesreal: floating-point type text: Character type blob stored in UTF-8,UTF-16BEORUTF-16LE encoding: binary data
Reference:
Http://www.4byte.cn/question/22141/saving-nsarray-in-sqlite-and-retrieving-it.html
Http://www.chengxuyuans.com/iPhone_IOS/37789.html
IOS sqlite3 Save Array Nsarray