Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8358353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:46:04+00:00 2026-06-09T10:46:04+00:00

-(void)insertDataToFavourites:(int)pageid :(NSString *)description { sqlite3_stmt *insertStatement = nil; NSString *sql; int returnvalue; sql =

  • 0
-(void)insertDataToFavourites:(int)pageid :(NSString *)description
{
    sqlite3_stmt *insertStatement = nil;
    NSString *sql;
    int returnvalue;

    sql = [NSString stringWithFormat:@"insert into AddFavorite (Id,Description) VALUES (?,?)"];

    returnvalue = sqlite3_prepare_v2(database, [sql UTF8String], -1, &insertStatement, NULL);

    if (returnvalue == 1){
        NSAssert1 (0,@"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
    }
    sqlite3_bind_text(insertStatement, 2,[[tempDict objectForKey:@"pageid"] UTF8String], -1, SQLITE_TRANSIENT);
    sqlite3_bind_text(insertStatement, 3,[[tempDict objectForKey:@"desc"] UTF8String], -1, SQLITE_TRANSIENT);
    if (SQLITE_DONE != sqlite3_step(insertStatement)){
        NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database));
    }
    else{
        sqlite3_reset(insertStatement);
    }

    sqlite3_finalize(insertStatement);

    if(sqlite3_exec(database, [sql UTF8String], NULL, NULL, NULL) != SQLITE_DONE ){
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert!" message:@"Data saved Successfully." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
        [alert show];
        [alert release];
    }

    else{
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert!" message:@"Data insertion error." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
        [alert show];
        [alert release];
    }

}

Above code i am doing for the insertion of the data to Sqlite Database table. This is showing me alert Data saved Successfully.
at the time of inserting data to Favorite list.

-(void)getFavoriteList
{

    if([ArrFav count] > 0)
        [ArrFav removeAllObjects];

    ArrFav = [[NSMutableArray alloc] init];

    sqlite3_stmt *selectStatement=nil;  
    NSString *sql;
    int returnvalue;

    sql=[NSString stringWithFormat:@"SELECT Description FROM AddFavorite"];

    returnvalue = sqlite3_prepare_v2(database, [sql UTF8String], -1, &selectStatement, NULL);

    if(returnvalue==1)
    {
        NSAssert1(0, @"Error: failed to select the database with message '%s'.", sqlite3_errmsg(database));
    }

    NSMutableDictionary *dict;
    NSString *str;
    if(returnvalue == SQLITE_OK)
    {                       
        while(sqlite3_step(selectStatement) == SQLITE_ROW)
        {   
            dict = [[NSMutableDictionary alloc] init];
            [dict setObject:[NSString stringWithUTF8String:(char *)sqlite3_column_text(selectStatement,1)] forKey:@"Description"];

            [ArrFav addObject:[dict objectForKey:@"Description"]];
            NSLog(@"Favorite data is:--> %@",ArrFav);
        }       
    }
}

This is the code to select data from sqlite database table. at the line [dict setObject:[NSString stringWithUTF8String:(char *)sqlite3_column_text(selectStatement,1)] forKey:@”Description”]; application is getting crashed.

Can anybody suggest me for the problem, why this problem is occured & what is the solution of this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T10:46:06+00:00Added an answer on June 9, 2026 at 10:46 am

    I think you are trying to set a nil value for a key in dictionary. This means you are not getting any result from your SELECT statement. Please check the contents of your DB by using Mozilla sqlite editor and see if the value your are trying to retrieve exists in your DB.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

-(IBAction)btnAddToFavorite:(id)sender { [self insertDataToFavourites:[[tempDict objectForKey:@pageid]intValue]:[tempDict objectForKey:@desc]]; } -(void)insertDataToFavourites:(int)pageid :(NSString *)description { sqlite3_stmt *insertStatement =
void max_min(sqlite3 *db) { //call back********* int i, ncols; sqlite3_stmt *stmt; char *sql; const
- (void) showMail { [[CCDirector sharedDirector] pause]; NSString*myemail=@sirano0629@me.com; NSArray*email=[[NSArray alloc]initWithObjects:myemail, nil]; if([MFMailComposeViewController canSendMail]) {
- (void)viewDidLoad{ [super viewDidLoad]; NSString *path = [[NSBundle mainBundle] pathForResource:@VidName ofType:@mov]; NSURL *url =
- (void)TargetHit:(int)target{ void (^threadBlock)(void) = ^{ NSLog(@respond to selector %d, [self respondsToSelector:@selector(changeImageOfTarget:)]); [[NSOperationQueue mainQueue]
- (void)connectionDidFinishLoading:(NSURLConnection *)connection { self.listFeedConnection = nil; // release our connection [UIApplication sharedApplication].networkActivityIndicatorVisible =
void foo(Node* p[], int size){ _uint64 arr_of_values[_MAX_THREADS]; for (int i=0 ; i < size
void AFCQueue::ExtractValuesSecComplex(int startIndex, int endIndex,int helperIndex) { int size = 0,i,index; TimeType min_timestamp; bool
void f(int){} typedef void (*f_ptr)(int); struct Functor{ void operator()(int){} }; struct X{ operator f_ptr(){
void child(int pid){ printf(Child PID:%d\n,pid); exit(0); } void parent(int pid){ printf(Parent PID:%d\n,pid); exit(0); }

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.