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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:21:36+00:00 2026-05-29T17:21:36+00:00

I need to develop an app in which I need to store the products

  • 0

I need to develop an app in which I need to store the products into a cart.Also I need to retrieve the recent orders in last first sort manner.
Which is the best way to store the data- using plist or SQLite Database?

  • 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-05-29T17:21:38+00:00Added an answer on May 29, 2026 at 5:21 pm

    I create that type of the application in which i use the Sqlite Database for that easy to manipulate rather then to .plist file.

    Below is the some amount of the code for inserting the item into DB.

    Init Database

    -(id)init{
        if(self=[super init]) {
            documentsDirectory_Statement;
            documentsDirectory=[documentsDirectory stringByAppendingPathComponent:@"DietCenter.rsd"];
            self.dbPath=documentsDirectory;
            NSFileManager *fm=[NSFileManager defaultManager];
            if(![fm fileExistsAtPath:self.dbPath]) {
                NSString *localDB=[[NSBundle mainBundle] pathForResource:@"DietCenter" ofType:@"rsd"];
                NSError *err;
                if(![fm copyItemAtPath:localDB toPath:self.dbPath error:&err]){
                    NSLog(@"Error in creating DB -> %@",err);
                }
            }
    
            if(sqlite3_open([self.dbPath UTF8String], &database) !=SQLITE_OK){
                NSLog(@"error while opening database.");
            } else {
                sqlite3_close(database);
            }
        }
        return self;
    }
    

    consent Values

      #define PUT_Value(_TO_,_FROM_) { \
            NSString *str=[dObj valueForKey:_FROM_]; \
            if(!str) str=@" "; \
            sqlite3_bind_text(compiledStmt,_TO_,[str UTF8String],-1,SQLITE_TRANSIENT); \
        }
    
        #define PUT_Integer(_TO_,_FROM_) { \
            NSInteger numbr=[[dObj valueForKey:_FROM_] intValue]; \
            sqlite3_bind_int(compiledStmt,_TO_,numbr); \
        }
    
    
        #define PUT_Double(_TO_,_FROM_) { \
        CGFloat doubleX=[[dObj valueForKey:_FROM_] floatValue]; \
        sqlite3_bind_double(compiledStmt,_TO_,doubleX); \
        }
    
    
    
        #define GET_Value(_TO_,_FROM_) NSString *_TO_; { \
        const unsigned char *c=sqlite3_column_text(compiledStmt,_FROM_); \
        _TO_= c ? [NSString stringWithUTF8String:(char*)c] : @"" ; \
        }
    
        #define GET_Double(_TO_,_FROM_) double _TO_;{ \
        _TO_=sqlite3_column_double(compiledStmt,_FROM_); \
        }
    
        #define GET_Integer(_TO_,_FROM_) NSUInteger _TO_; { \
        _TO_ = sqlite3_column_int(compiledStmt,_FROM_); \
        }
    

    Insert Value Function
    -(void)insertItem:(NSArray*)arItem{

        sqlite3_stmt *compiledStmt;
        if(sqlite3_open([self.dbPath UTF8String], &database) ==SQLITE_OK) {
    
    
            sqlite3_prepare_v2(database, "BEGIN TRANSACTION", -1, &compiledStmt, NULL);
            sqlite3_step(compiledStmt);
            sqlite3_finalize(compiledStmt);
    
            const char *sqlInsertQry="insert into CartDetails (id,cat_id,KD,item,qty,calories,ar_name) values(?,?,?,?,?,?,?)";
            if(sqlite3_prepare_v2(database, sqlInsertQry, -1, &compiledStmt, NULL) == SQLITE_OK ){
                for (NSDictionary *dObj in arItem) {
                    PUT_Integer(1,@"id");
                    PUT_Integer(2,@"Cat_Id");
                    PUT_Double(3,@"KD");
                    PUT_Value(4,@"item");
                    PUT_Integer(5,@"qty");
                    PUT_Value(6,@"calories");
                    PUT_Value(7,@"ar_name");                
    
                    NSUInteger err = sqlite3_step(compiledStmt);
                    if (err != SQLITE_DONE){
                        NSLog(@"error while binding %d %s",err, sqlite3_errmsg(database));
                    }
                    sqlite3_reset(compiledStmt);
                }
                sqlite3_finalize(compiledStmt);     
            } else {
                NSLog(@"Invalid Query");
            }
            sqlite3_prepare_v2(database, "END TRANSACTION", -1, &compiledStmt, NULL);
            sqlite3_step(compiledStmt);
            sqlite3_finalize(compiledStmt); 
            sqlite3_close(database);
        } else {
            NSLog(@"error while opening database.");
        }
    }
    

    If you have any query related this please tell me i help to u

    Thanks and Regards,

    @ Samuel

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

Sidebar

Related Questions

I am trying to develop an iPad app in which I need to have
I need to develop an app that runs side by side with a django-app.
I need to develop a point of sale app that will be used on
I need to develop an application which stores data in a SQL Server 2005
I need to develop a CRM system which will allow users to have a
I'm quite new in iPhone development and I need to develop an app. I
I have certain sound files and will like to develop an app which allows
I need to develop a Instant Lottery game app. I need an idea/procedure to
I need to develop a basic web app very quickly (1 week) for a
For a project I need to develop an app in Adobe AIR, I choose

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.