views:

16

answers:

1

My application has a sqlite database and i m using executeQuery methods to retrive and insert data.

Problem

I cannot assign integer values cells of tableview. It does not display data which is in integer format. i want to store integer values into a tableview and show sorted integer data to user.

Here i am posting my code

1) in viewDidLoad i have retrieved integer values from database table "dummy" and taken it into an NSArray "Scores"

2) i have assigned a value of "highscore" which is an integer type to cell in "cellForRowAtIndexPath" Method of table view.Note that converting this data into NSString does not allow sorting.

But this shows no data in table cells when i run it.

1)

NSString *myDBnew = @"/Users/taxsmart/Documents/sqlite/atest.sql";

database = [[Sqlite alloc] init];

[database open:myDBnew];

Scores = [database executeQuery:@"SELECT * FROM dummy ORDER BY highscore DESC;"];

2)

cell.textLabel.text = [[Scores objectAtIndex:indexPath.row] valueForKey:@"highscore"];

What is Wrong?

Please Give Your Suggestions. Your Suggestions are most welcome.

A: 

You must assign an NSString* to cell.textLabel.text. Just embedd your ints into an NSString.

NSInteger highscore = [[Scores objectAtIndex:indexPath.row] valueForKey:@"highscore"];
cell.textLabel.text = [NSString stringWithFormat:@"%d", highscore];
fluchtpunkt