If you take a look at the picture I provided, on the left hand side there is a table. This table loads SQLite data. The SQLite data has some data retrieved from a MYSQL database. The SQLite data is the following columns:
StoreID, StoreName, StoreAddr, StoreHost, StorePort, StoreUser, StorePass, StoreDB.
What's showing up in the table cell is clearly the StoreName and StoreAddr
On the right hand side of my picture, you can see some code that is implemented for the didSelectRowAtIndexPath method. The selection of a cell causes a segue to a view controller that calls MYSQL data specific to the SQLite credentials from the cell. For example, if I clicked Latin Bites Peruvian Cuisine, it should use the SQLite credentials to log into MYSQL and then parse the information back to the program.
My question is: How do I have the 'Latin Bites' cell grab SQLite info to be used as MYSQL credentials?
I can't target each individual cell's data. If there was just one entry in SQLite, then I would do a code similar to this:
sqlite3_stmt *statement;
if (sqlite3_open([dbPathString UTF8String], &companyDB)==SQLITE_OK) {
[arrayOfStore removeAllObjects];
NSString *querySql = [NSString stringWithFormat:@"SELECT * FROM storelist"];
const char* query_sql = [querySql UTF8String];
if (sqlite3_prepare(companyDB, query_sql, -1, &statement, NULL)==SQLITE_OK) {
while (sqlite3_step(statement)==SQLITE_ROW) {
// Statement 1,2,3 etc. relates to the SQLite table in order.
NSString *name = [[NSString alloc]initWithUTF8String:(const char *)sqlite3_column_text(statement, 1)];
NSString *address = [[NSString alloc]initWithUTF8String:(const char *)sqlite3_column_text(statement, 2)];
NSString *host = [[NSString alloc]initWithUTF8String:(const char *)sqlite3_column_text(statement, 3)];
NSString *pass = [[NSString alloc]initWithUTF8String:(const char *)sqlite3_column_text(statement, 6)];
NSString *db = [[NSString alloc]initWithUTF8String:(const char *)sqlite3_column_text(statement, 7)];
NSString *dateString = [NSDateFormatter localizedStringFromDate:[NSDate date]
dateStyle:NSDateFormatterShortStyle
timeStyle:NSDateFormatterFullStyle];
NSString *salesStr = @"http://";
salesStr = [salesStr stringByAppendingString:host];
salesStr = [salesStr stringByAppendingString:@":8080/sales.php?password="];
salesStr = [salesStr stringByAppendingString:pass];
salesStr = [salesStr stringByAppendingString:@"&db="];
salesStr = [salesStr stringByAppendingString:db];
salesStr = [salesStr stringByAppendingString:@"&edate="];
salesStr = [salesStr stringByAppendingString:dateString];
salesStr = [salesStr stringByAppendingString:@"&sdate="];
salesStr = [salesStr stringByAppendingString:dateString];
NSURL * url = [NSURL URLWithString:salesStr];
NSData * data = [NSData dataWithContentsOfURL:url];
json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
NSLog(@"response type is %@",[json class]);
//Set up our cities array
storesArray = [[NSMutableArray alloc]init];
for (int i = 0; i < json.count; i++)
{
NSString * netSales = [[json objectAtIndex:i] objectForKey:@"netSales"];
NSString * voids = [[json objectAtIndex:i] objectForKey:@"voidSales"];
NSString * discounts = [[json objectAtIndex:i] objectForKey:@"discountSales"];
NSString * guestCount = [[json objectAtIndex:i] objectForKey:@"guestCount"];
NSString * peopleServed = [[json objectAtIndex:i] objectForKey:@"servedCount"];
NSString * employeesClock = [[json objectAtIndex:i] objectForKey:@"loggedIn"];
Store * myStore = [[Store alloc]initWithNetSales: (NSString *) netSales andVoids: (NSString *) voids andDiscounts: (NSString *) discounts andGuestCount: (NSString *) guestCount andPeopleServed: (NSString *) peopleServed andEmployeesClock: (NSString *) employeesClock];
[storesArray addObject:myStore];
But I need to have each individual cell pull it's SQLite data to be used as MYSQL credentials. Any suggestions?