मैं वर्तमान में मेरे iPhone आवेदन के हिस्से के रूप में निम्नलिखितiPhone
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSString *filePath = [documentsPath stringByAppendingPathComponent:@"cities.sqlite"];
sqlite3 *database;
if(sqlite3_open([filePath UTF8String], &database) == SQLITE_OK) {
const char *sqlStatement = "insert into table (name, description, image) VALUES (?, ?, ?)";
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
sqlite3_bind_text(compiledStatement, 1, [name UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(compiledStatement, 2, [description UTF8String], -1, SQLITE_TRANSIENT);
NSData *dataForImage = UIImagePNGRepresentation(image);
sqlite3_bind_blob(compiledStatement, 3, [dataForImage bytes], [dataForImage length], SQLITE_TRANSIENT);
}
if(sqlite3_step(compiledStatement) != SQLITE_DONE) {
NSLog(@"Error: %s", sqlite3_errmsg(database));
} else {
NSLog(@"Insert into row id = %d", sqlite3_last_insert_rowid(database));
}
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
क्या मुझे भ्रमित कर रहा है कर रहा हूँ कि अगर मैं अनुभाग,
if(sqlite3_step(compiledStatement) != SQLITE_DONE) {
NSLog(@"Error: %s", sqlite3_errmsg(database));
} else {
NSLog(@"Insert into row id = %d", sqlite3_last_insert_rowid(database));
}
बाहर ले INSERT डेटाबेस में सहेजा नहीं गया है और खो जाता है। मुझे लगता है कि मैं यहाँ कुछ स्पष्ट याद कर रहा हूँ?
मैं कोर डेटा का उपयोग नहीं कर के लिए अपने कारण (ओं) के उत्सुक हूँ। – nicerobot
मैं आमतौर पर SQLite के आस-पास कुछ रैपर का उपयोग करता हूं, या अधिकतर इन दिनों, कोर डेटा से अधिक नहीं। हालांकि मैं जानना चाहता था कि पुस्तकालय का उपयोग कैसे करें, इसलिए ... –