2011-05-17 45 views

回答

0

您需要某種類型的持久性存儲。根據您添加的內容,您可能能夠使用NSUserDefaults,或者您可能需要.plist,或者您可能需要像Core Data這樣更強大的功能。如果不知道你的需求,真的很難說。

0

我已經做了一個添加到收藏夾concept.First你創建一個表(id,fieldname1,fieldname2,狀態)在sqlite.Then插入你的數據到相應的領域。這是我的code.i剛剛通過ID和更新居留制

- (空)了updateData {

NSString * dt=show.id; 

const char *sql = "update quotesdet set status = ? where id = ?;"; 


    if ((sqlite3_prepare_v2(database, sql, -1, &updateStmt, NULL))!=SQLITE_OK) 
    { 
     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"DatabaseNotAvailable", @"") message:[NSString stringWithUTF8String:sqlite3_errmsg(database)] 
                 delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
     [alert show]; 
     [alert release]; 

    } 

NSString *s = @"true"; 

sqlite3_bind_text(updateStmt, 1, [s UTF8String], -1, SQLITE_TRANSIENT); 
NSInteger n = [dt intValue]; 
sqlite3_bind_int(updateStmt, 2, n); 
int success = sqlite3_step(updateStmt); 
if (success == SQLITE_ERROR) { 
    NSAssert1(0, @"Error: failed to insert into the database with message '%s'.", sqlite3_errmsg(database)); 
    //return NO; 
} 
else { 

    sqlite3_finalize(updateStmt); 

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Message" message:@"Added Successfully" 
                delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
    [alert show]; 
    [alert release]; 

} 

}