SQLite Access in Objective-C and Cocoa
I am in the process of learning Objective-C for Mac/iPhone development and decided to try and write something useful without looking at the bible (Aaron Hillegass: Cocoa Programming 3rd Edition).
I'm writing a simple puzzle gam开发者_StackOverflowe. The data that defines the levels is stored as a string in a SQLite database and read into a level object with this line of code:
tempLevel.levelData = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
I have two other lines that read in other properties from the database (integers this time, not strings) and they work fine so I am wondering if anyone can help me with the problem.
When this line of code executes I get the following error: *** +[NSString stringWithUTF8String:]: NULL cString
I would greatly appreciate any help you can give. If you need any more information I would be glad to provide it.
Thanks!
Not really an answer, but there's no good reason to deal with sqlite directly when there are some great wrappers available:
http://cocoaheads.byu.edu/resources/sqlite
Most likely it is an error in compiledStatement
. As a general point, you should check that you get an actual value from sqlite3_column_text
first, since getting back NULL
is often the "correct" response to what you ask for.
精彩评论