开发者

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

开发者 https://www.devze.com 2023-01-20 00:13 出处:网络
i m using sqlite i am geting a return value frmo DB in this manner re开发者_StackOverflow中文版turnCount = [NSStringstringWithUTF8String:(char *)sqlite3_column_text(selectstmt,0)];

i m using sqlite

i am geting a return value frmo DB in this manner

re开发者_StackOverflow中文版turnCount = [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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消