如何将“添加到收藏夹”功能添加到选项卡栏应用程序中?

时间:2011-05-17 00:08:37

标签: iphone

我只是想知道用什么代码将“添加到收藏夹”功能添加到我的应用中?

任何帮助都会很棒!

2 个答案:

答案 0 :(得分:0)

您需要某种类型的持久存储。根据您添加的内容,您可能可以使用NSUserDefaults,或者您可能需要.plist,或者您可能需要更强大的功能,如Core Data。在不了解您的需求的情况下真的很难说。

答案 1 :(得分:0)

我已经添加了收藏夹概念。首先在sqlite中创建一个表(id,fieldname1,fieldname2,status)。然后将数据插入到相应的字段中。这是我的code.i刚刚传递了id并更新了staus

- (void)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];

}

}