Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(UIImage *) getPointImage:(NSString *)pointName
- {
- UIImage *retImg;
- const char *sql = "SELECT image from Image where name=?";
- sqlite3_stmt *statement;
- // Preparing a statement compiles the SQL query into a byte-code program in the SQLite library.
- // The third parameter is either the length of the SQL string or -1 to read up to the first null terminator.
- int result = sqlite3_prepare(imgDatabase, sql, -1, &statement, NULL);
- if (result == SQLITE_OK)
- {
- //fill in the name of the point we are looking for
- sqlite3_bind_text(statement, 1, [pointName UTF8String], -1, SQLITE_TRANSIENT);
- // We "step" through the results - once for each row.
- while (sqlite3_step(statement) == SQLITE_ROW)
- {
- int dataSize = sqlite3_column_bytes(statement, 0);
- NSMutableData *data = [NSMutableData dataWithLength:dataSize];
- memcpy([data mutableBytes], sqlite3_column_blob(statement, 0), dataSize);
- retImg = [[UIImage alloc] initWithData:data];
- }
- }
- // "Finalize" the statement - releases the resources associated with
- //the statement.
- sqlite3_finalize(statement);
- return retImg;
- }
Add Comment
Please, Sign In to add comment