• 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
Re: Persisting in SQLite3 / XCode4.2 even after the app is quit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


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

Thanks for your reply. My only issue is with instantiating the DatabaseOperations class (which does the DB operations) in the ViewController. Where can I move the instantiation logic so that the DB isn't wiped off after the app quits?


On Sun, Apr 15, 2012 at 1:31 PM, Christian Unger <email@hidden> wrote:
try using CoreData

cu
christian unger


------------------------------
 - sent from iPhone -

On 15.04.2012, at 09:50, The Rhythmic <email@hidden> wrote:

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)

This email sent to email@hidden

 _______________________________________________
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

References: 
 >Persisting in SQLite3 / XCode4.2 even after the app is quit (From: The Rhythmic <email@hidden>)

  • Prev by Date: Re: Creating an IPA in Xcode 4.2 / Code Signing
  • Next by Date: Re: Creating an IPA in Xcode 4.2 / Code Signing
  • Previous by thread: Persisting in SQLite3 / XCode4.2 even after the app is quit
  • Next by thread: Um, what is the process to duplicate a class?
  • Index(es):
    • Date
    • Thread