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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-15-2011, 02:56 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 7
Dalterego is on a distinguished road
Default Please i need a help with array result.

My question is:

I have a Class PersonViewController

This Class access to a sqlite database through the method readFromDatabase,

this is the method readFromDatabase:

Code:
############################################

- (void) readDataFromDatabase{

	sqlite3 *database;
	persons = [[NSMutableArray alloc]init];
	
	if (sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
		
		// Randon numbers (0, 1 y 3)
		int r = arc4random() % 3;
		NSLog(@"%i",r);
		if (r==0) {
			r=3;
		}
		
		NSString *s = [NSString stringWithFormat:@"SELECT * from person WHERE id = %i", r];
		
		const char *sqlStatement = [s cStringUsingEncoding:NSASCIIStringEncoding];
		
		//const char *sqlStatement = "SELECT * FROM person WHERE id=1";
		sqlite3_stmt *compiledStatement;
		
		if (sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
			
			while (sqlite3_step(compiledStatement) == SQLITE_ROW) {
				
				NSInteger pID = sqlite3_column_int(compiledStatement, 0);
				NSString *pName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
				NSInteger pAge = sqlite3_column_int(compiledStatement, 2);
				
				Person *temp = [[Person alloc] initWhitID:pID name:pName andage:pAge];
				
				//[consulta ]
				[persons addObject:temp];
				[temp release];
						
				NSLog(@"ID: %i, Nombre: %@, Edad: %i",pID,pName,pAge);
				
			}
			
		}
		sqlite3_finalize(compiledStatement);
	}
	sqlite3_close(database);


############################################
I need to pass result in the while of the method to another class.

when i try to pass it to another class i only see many numbers, i think that is a reference to the value, I think!

for example inside the while is possible to do this:
NSLog(@"Value: %@",pName);

but in another class is possible to see any value inside this method, but is not possible to see the value from the array, because only see many numbers.

Sorry for the question, I`m very very new in the OOP...

Thanks for all...

Last edited by Dalterego; 01-15-2011 at 03:10 PM.
Dalterego is offline   Reply With Quote
Old 01-16-2011, 05:18 AM   #2 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 7
Dalterego is on a distinguished road
Default

Please anybody help me with this please, is only arrays
Dalterego is offline   Reply With Quote
Old 01-17-2011, 01:43 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 7
Dalterego is on a distinguished road
Default

Hehehe no body???
Dalterego is offline   Reply With Quote
Reply

Bookmarks

Tags
array

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 363
10 members and 353 guests
7twenty7, blueorb, dre, iAppDeveloper, iGamesDev, Mah6447, Morrisone, mottdog, sacha1996, Touchmint
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:37 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0