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 8406449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:06:47+00:00 2026-06-09T23:06:47+00:00

I’m totally new with SQLite. I have a UITableview with contains different days in

  • 0

I’m totally new with SQLite. I have a UITableview with contains different days in it. (Monday till sunday). When i click on for example Monday an other viewcontroller contains with also a UITableview inside it. In the same viewcontroller i have a UIButton when i click on it i can add data to my SQLite database [A], i insert the name and the day of the week (The day of the week is in this example ‘monday’ that’s because i clicked on the monday view controller).

When i insert a name it appears in my tableview. But when i go back to my first viewcontroller with the days and i click for example on Wednesday the data i added also appear there.

So my question is; How can i show the name which i inserted in monday, only in the monday tableview and not the other days(tableviews)

More information:

So when a user adds a name in ‘monday’ i send the dayoftheweek with the added name to the SQLite database, when a user adds a name in wednesday i send ‘dayoftheweek’ Wednesday etc..

Database Coffee looks like =

CoffeeName    | dayoftheweek
-------------------------
Hello world   | Monday
Hello Planet  | Wednesday
Hello Animal  | Monday
Hello STOVW   | Friday

[A] const char *sql = "insert into Coffee(CoffeeName, dayoftheweek) Values(?, ?)";

I need to check if the day (for example) monday is the same as dayoftheweek (monday) and then display al the items which contains ‘dayoftheweek monday’

My sqlite looks like:

+ (void) getInitialDataToDisplay:(NSString *)dbPath {


    if (sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK) {


        const char *sql = "select coffeeID, coffeeName from coffee";
        sqlite3_stmt *selectstmt;
        if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK) {

            while(sqlite3_step(selectstmt) == SQLITE_ROW) {

                NSInteger primaryKey = sqlite3_column_int(selectstmt, 0);
                Coffee *coffeeObj = [[Coffee alloc] initWithPrimaryKey:primaryKey];
                coffeeObj.LessonName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 1)];

               coffeeObj.dayoftheweek = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 1)];

                coffeeObj.isDirty = NO;

                [appDelegate.coffeeArray addObject:coffeeObj];
            }
        }
    }
    else
        sqlite3_close(database); //Even though the open call failed, close the database connection to release all the memory.
}


- (void) addCoffee1 {


    if(addStmt == nil) {
        const char *sql = "insert into Coffee(CoffeeName, dayoftheweek) Values(?, ?)";
        if(sqlite3_prepare_v2(database, sql, -1, &addStmt, NULL) != SQLITE_OK)
            NSAssert1(0, @"Error while creating add statement. '%s'", sqlite3_errmsg(database));
    }



    sqlite3_bind_text(addStmt, 1, [dayoftheweek UTF8String], -1, SQLITE_TRANSIENT);

    if(SQLITE_DONE != sqlite3_step(addStmt))
        NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database));
    else
        //SQLite provides a method to get the last primary key inserted by using sqlite3_last_insert_rowid
        LesID = sqlite3_last_insert_rowid(database);

    //Reset the add statement.
    sqlite3_reset(addStmt);
}

Insert:

coffeeObj.dayoftheweek = [NSString stringWithFormat:@"%@", dayoftheweek];

this insert: monday tuesday wednesday thursday friday saturday or sunday

But how can i display the data which is inserted in monday in the monday tableview and the data which is inserted in tuesday in the tuesday controller etc.

i tried ;

if([coffeeObj.dayoftheweek isEqualToString:@"Monday"]) {

cell.day.text = coffeeObj.LessonName;


} else {

}

Display:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CustomCellIdentifier = @"DaycusViewController";
    DaycusViewController *cell = (DaycusViewController *)[tableView dequeueReusableCellWithIdentifier: CustomCellIdentifier];


    if (cell == nil) {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"DaycusViewController"
                                                     owner:self options:nil];
        for (id oneObject in nib) if ([oneObject isKindOfClass:[DaycusViewController class]])
            cell = (DaycusViewController *)oneObject;
    }


    //Get the object from the array.
    Coffee *coffeeObj = [appDelegate.coffeeArray objectAtIndex:indexPath.row];



    cell.Name.text = CoffeeObj.CoffeeID;
    cell.Day.text =  CoffeeObj.dayoftheweek;


    //i tried this: (not working)

/* begin */
if([CoffeeObj.dayoftheweek isEqualToString:@”Monday”]) {

        //  cell.Name.text = CoffeeObj.CoffeeID;
    //cell.Day.text =  CoffeeObj.dayoftheweek;

    } else {

    }
    /* end */

//it need's to display in this example only things where dayoftheweek is monday but.
    return cell;
}

call to function getInitialDataToDisplay

//Copy database to the user's phone if needed.
[self copyDatabaseIfNeeded];

//Initialize the coffee array.
NSMutableArray *tempArray = [[NSMutableArray alloc] init];
self.coffeeArray = tempArray;
[tempArray release];

//Once the db is copied, get the initial data to display on the screen.
[Coffee getInitialDataToDisplay:[self getDBPath]];
  • 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-09T23:06:49+00:00Added an answer on June 9, 2026 at 11:06 pm

    It’s hard to understand your question but i think you can better open a new project and start with Core Data. It’s easy to understand and it’s faster than SQLite.

    Core Data is a framework Apple provides to developers that is described as a “schema-driven object graph management and persistence framework.” What does that actually mean? The framework manages where data is stored, how it is stored, data caching, and memory management. It was ported to the iPhone from Mac OS X with the 3.0 iPhone SDK release.

    The Core Data API allows developers to create and use a relational database, perform record validation, and perform queries using SQL-less conditions. It essentially allows you to interact with SQLite in Objective-C and not have to worry about connections or managing the database schema

    More about Core Data:

    • https://developer.apple.com/technologies/ios/data-management.html
    • https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/CoreData/cdProgrammingGuide.html
    • https://developer.apple.com/library/ios/#referencelibrary/GettingStarted/GettingStartedWithCoreData/_index.html

    I wish you all the luck with your application, but i’m for sure that Core Data is the best for your application!

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

Sidebar

Related Questions

I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.