Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 02-15-2010, 08:16 PM   #8 (permalink)
tsansone
Registered Member
 
Join Date: Feb 2010
Posts: 11
Default

Ok, I tried putting the code in the header and got nowhere. I appreciate you trying to help me. I am attaching code for my files that need to be modified (I believe). I would appreciate it if you could help with this.

VGTData.h file
Code:
#import <Foundation/Foundation.h>
#import <sqlite3.h>
#import "VGTDataUser.h"
#import "VGTGame.h"
#import "VGTManufacturer.h"
#import "VGTPlatform.h"

@interface VGTData : NSObject
{
    sqlite3 *readonlyDatabase;
    sqlite3 *writableDatabase;
	NSArray *manufacturers;
	BOOL shouldReloadUserHaves;
	BOOL shouldReloadUserWants;
	NSMutableSet *dataUsers;
	NSMutableSet *haveGames[OwnedStateCOUNT];
	NSMutableSet *wantGames[OwnedStateCOUNT];
	NSMutableDictionary *havePlatforms;
	NSMutableDictionary *wantPlatforms;
}

@property (nonatomic, assign) sqlite3 *readonlyDatabase;
@property (nonatomic, assign) sqlite3 *writableDatabase;
@property (nonatomic, retain) NSArray *manufacturers;

+ (VGTData *)sharedInstance;
+ (void)appWillTerminate;

- (id)init;
- (void)createFavoritesTables;
- (UIImage *)imageForManufacturer:(VGTManufacturer *)manufacturer;
- (UIImage *)imageForPlatform:(VGTPlatform *)platform;
- (NSArray *)platformsWithText:(NSString *)searchText;
//- (NSArray *)gamesForPlatform:(VGTPlatform *)platform;

- (void)addDataUser:(id <VGTDataUser>)aUser;

- (BOOL)loadDatabaseUpdate:(NSData *)aData;

- (NSDictionary *)havePlatforms;
- (NSDictionary *)wantPlatforms;

- (NSSet *)haveCompleteGames;
- (NSSet *)haveLooseGames;
- (NSSet *)wantCompleteGames;
- (NSSet *)wantLooseGames;

- (OwnedState)haveItStateForGame:(NSString *)primaryKey;
- (OwnedState)wantItStateForGame:(NSString *)primaryKey;

- (void)setHaveState:(OwnedState)newState forGame:(NSString *)primaryKey;
- (void)setWantState:(OwnedState)newState forGame:(NSString *)primaryKey;

- (BOOL)shouldReloadUserHaves;
- (BOOL)shouldReloadUserWants;

- (void)userHavesDidChange;
- (void)userWantsDidChange;

@end
VGTData.m file
Code:
#import "VGTData.h"
#import "VGTManufacturer.h"
#import "VGTPlatform.h"
#import "VGTGame.h"
#import "JHSQLiteCocoa.h"
#import <sqlite3.h>

@interface VGTData ()
- (void)initializeDatabase;
- (void)closeDatabase;
@end


@implementation VGTData

VGTData *VGTData__instance = nil;
static sqlite3_stmt *search_statement = NULL;

static sqlite3_stmt *hydrate_have_platforms_statement = NULL;
static sqlite3_stmt *hydrate_have_statement = NULL;
static sqlite3_stmt *query_have_statement = NULL;
static sqlite3_stmt *delete_have_statement = NULL;
static sqlite3_stmt *insert_have_statement = NULL;

static sqlite3_stmt *hydrate_want_platforms_statement = NULL;
static sqlite3_stmt *hydrate_want_statement = NULL;
static sqlite3_stmt *query_want_statement = NULL;
static sqlite3_stmt *delete_want_statement = NULL;
static sqlite3_stmt *insert_want_statement = NULL;

@synthesize readonlyDatabase;
@synthesize writableDatabase;
@synthesize manufacturers;

+ (VGTData *)sharedInstance
{
	//DLog(@"%s (%@)", __FUNCTION__, VGTData__instance);
	if (VGTData__instance == nil)
	{
		VGTData__instance = [[VGTData alloc] init];
	}
	return VGTData__instance;
}

+ (void)appWillTerminate
{
	[VGTData__instance closeDatabase];
}

- (void)createFavoritesTables
{
	static BOOL did_create_have_table = NO;
	static BOOL did_create_want_table = NO;
	if (did_create_have_table == NO)
	{
		did_create_have_table = YES;
		
		sqlite3_stmt *statement = NULL;
		const char *sql = "CREATE TABLE IF NOT EXISTS user_have(gameId TEXT PRIMARY KEY, state INT)";
		int result = sqlite3_prepare_v2(writableDatabase, sql, -1, &statement, NULL);
		//DLog(@"(%d)", result);
		if (result != SQLITE_OK)
		{
			DLog(@"");
			NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(writableDatabase));
		}
		int success = sqlite3_step(statement);
		//DLog(@"(%d)", success);
		result = sqlite3_finalize(statement);
		DLog(@"(%d)", result);
	}
	if (did_create_want_table == NO)
	{
		did_create_want_table = YES;
		
		sqlite3_stmt *statement = NULL;
		const char *sql = "CREATE TABLE IF NOT EXISTS user_want(gameId TEXT PRIMARY KEY, state INT)";
		int result = sqlite3_prepare_v2(writableDatabase, sql, -1, &statement, NULL);
		//DLog(@"(%d)", result);
		if (result != SQLITE_OK)
		{
			DLog(@"");
			NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(writableDatabase));
		}
		int success = sqlite3_step(statement);
		//DLog(@"(%d)", success);
		result = sqlite3_finalize(statement);
		DLog(@"(%d)", result);
	}
}

- (void)dealloc
{
	[manufacturers release];
	[super dealloc];
}

// There is actually more code then this but I think this is all you will need //
I know this is a lot of code to look into and even perhaps outside the scope of this forum. But I am beginner at this and I am stuck. Thanks
tsansone is offline   Reply With Quote
 

» Advertisements
» Online Users: 285
19 members and 266 guests
ADY, apatsufas, BdR, Diegan, djohnson, Duncan C, F_Bryant, glenn_sayers, Guthook, ilmman, joeallenpro, Music Man, NSeven, Profile, rodgo, VikMyr, vogueestylee, zbynda, ziocleto
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,876
Threads: 89,225
Posts: 380,708
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jorge599
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:03 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.