• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Persisting in SQLite3 / XCode4.2 even after the app is quit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Persisting in SQLite3 / XCode4.2 even after the app is quit


  • Subject: Persisting in SQLite3 / XCode4.2 even after the app is quit
  • From: The Rhythmic <email@hidden>
  • Date: Sun, 15 Apr 2012 13:20:42 +0530

Am a newbie to App development (to Apple related development itself, I should say!) I am writing a simple app, in which am doing some simple SQLite3 operations to store and retrieve data.


In the ViewController class:

On button press in the UI, am persisting some data into the database. And also, consequently retrieving and displaying some data. 


In another class called DatabaseOperations (I have put in all database related operations into this):

I have methods which do storage/retrieval of data.


The above code works fine for me. The only problem is with 'calling' the methods in DatabaseOperations from the ViewController.


In order to do this, am instantiating DatabaseOperations class in 'viewDidLoad' of ViewController. There is a problem with this approach, because, as you might have guessed, the data persisted in the DB gets wiped off every time I quit the app. Initially I was having DB operations too in the ViewController class itself. At that time, this wiping-off didn't happen. 


I tried making the methods in the DatabaseOperations class as 'class methods' (putting a '+', instead of '-'), but that is causing other errors as am using some instance variables in those methods, which is not compliant.


How can I make sure that the data in SQLite3 is not wiped off after I quit the app? Please help!




This is the code snippet:



VIEW CONTROLLER CLASS


// import and synthesize statements 


DatabaseOperations *dbOps;


…

…

- (void)viewDidLoad

{

    dbOps = [[DatabaseOperations alloc] init];

    [dbOps openDB];

…

}




DATABASEOPERATIONS iNTERFACE:


#import <Foundation/Foundation.h>

#import "sqlite3.h"


@interface DatabaseOperations : NSObject


@property (nonatomic) sqlite3 *database;



// Method to open the database

-(void) openDB;


…



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Where does XCode 4.3.2 store account information?
  • Next by Date: Re: Clearing the debug console
  • Previous by thread: Re: Registering for the iOS Developer Program with another person's credit card
  • Next by thread: Re: Persisting in SQLite3 / XCode4.2 even after the app is quit
  • Index(es):
    • Date
    • Thread