views:

202

answers:

3

Hi,

I am trying to write a sqlite resultset wrapper class for the iPhone, and I would like to be able to dynamically call sqlite3_column_int or sqlite3_column_text?

For example, in my fetchAll method, I would like to not know what exact data i'm returning, I just want to return it.

My goal is to have a class that doesn't care what data you have in the database, it gets you what you want, and it doesn't need to worry about the type of data.

I was thinking of using performSelector but i'm not sure how that would work.

How would I design such a class to make it easier for clients of the class to interact with sqlite?

Thanks!

+1  A: 

No, you can't use an Objective-C feature to call a C function in that way (performSelector that is). You can call C code within objective-C. One approach may be to keep function pointers to the C functions you want to call, then implement some logic to choose the appropriate function pointer to reference.

darren
+1  A: 

I'm not quite sure I understand, but I suppose you might be able to write a few Objective-C methods containing small amounts of pure C and call performSelector on those. Unfortunately the SQLite3 API for the iPhone kind of sucks.

David Kanarek
+1  A: 

You could take a look at how other wrappers do it. For example, here's the source of the resultset object from Flying Meat Database: http://code.google.com/p/flycode/source/browse/trunk/fmdb/src/FMResultSet.h http://code.google.com/p/flycode/source/browse/trunk/fmdb/src/FMResultSet.m

Dave DeLong
@Dave, Thanks! :)
Jacob Relkin