Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(NSMutableArray *)getCatNames{
- //select sponser details
- //create sql string
- NSString *sql = [NSString stringWithFormat:@"SELECT name FROM categories;"];
- //create sql statement
- sqlite3_stmt *statment;
- //create array to sti0re all the entires in.
- NSMutableArray *sponsors =[[NSMutableArray alloc]init ];
- //check to make sure statement runs ok
- if (sqlite3_prepare_v2(db, [sql UTF8String], -1, &statment, nil) == SQLITE_OK) {
- //foreach row
- while (sqlite3_step(statment)==SQLITE_ROW) {
- //get the column text
- char *field = (char *) sqlite3_column_text(statment, 0);
- //assign the text to a string
- NSString *strField = [[NSString alloc]initWithUTF8String:field];
- //add each field string to the array
- [sponsors addObject:strField];
- }
- }
- NSLog(@"sponsors array: %@",sponsors);
- return sponsors;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement