Shishir.bobby
Shishir.bobby

Reputation: 10984

[NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt,0)];

i m using sqlite

i am geting a return value frmo DB in this manner

returnCount = [NSString  stringWithUTF8String:(char *)sqlite3_column_text(selectstmt,0)];

but the returend value is an integer value. how can i get a int value instead of paasing it in string...like this thing here

[NSString  stringWithUTF8String:(char *)sqlite3_column_text(selectstmt,0)];

is for string, is there any way to get it in "integer" right away, otherwise i need to cast it.

suggestions please.

Upvotes: 0

Views: 2061

Answers (1)

John Franklin
John Franklin

Reputation: 4912

The simplest answer, since it seems you know it's going to be an integer count, read it as an int with sqlite3_column_int().

That said, you may want to refactor your code after you drop in FMDB. FMDB will do the conversion for you when pulling data from integer or float columns. In your case, the result of a SELECT count(*) FROM myTable... would be a a single column of type integer and the [resultSet valueForkey:@"count"] will be an NSNumber as expected.

Upvotes: 2

Related Questions