简体   繁体   English

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

[英]How do I add the 'Add To Favourites' Feature into a Tab Bar App?

I'm just wondering what code I would use to add a 'Add To Favourites' feature into my app? 我只是想知道我将使用什么代码在应用程序中添加“添加到收藏夹”功能?

Any help would be awesome! 任何帮助都是极好的!

You need some type of persistent storage. 您需要某种类型的持久性存储。 Depending on what you're adding, you may be able to use NSUserDefaults, or you might need a .plist or you might need something more robust like Core Data. 根据要添加的内容,您可能可以使用NSUserDefaults,或者可能需要.plist,或者可能需要更强大的功能(如Core Data)。 Really hard to say without knowing your needs. 不知道您的需求真的很难说。

Already i did a add to favourites concept.First you create a table(id,fieldname1,fieldname2,status) in sqlite.Then insert your data into a corresponding fields. 我已经做了一个添加到收藏夹的概念。首先在sqlite中创建一个表(id,fieldname1,fieldname2,status)。然后将数据插入到相应的字段中。 this is my code.i have just pass the id and update the staus 这是我的代码。我刚刚传递了ID并更新了状态

-(void)updatedata { -(无效)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];

}

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM