views:

17

answers:

1

Heres my array

NSMutableArray *arrayTmp= [[NSMutableArray alloc] init];

I populate it like this

double price = sqlite3_column_double(stm, 3);   
double accumPrice = sqlite3_column_double(stm, 4);

[arrayTmp addObject:[NSDictionary dictionaryWithObjectsAndKeys:desc,@"desc",
    due,@"due", price,@"price", accumPrice,@"accum",nil]];  

I assign it to a variable for use in my UITableView

self.transactionsArray = arrayTmp;
[arrayTmp release];

Which in my h file is a NSMutableArray

    NSMutableArray *transactionsArray;

Now in my CellForRowAtIndexPath I can call strings but I can't pull out doubles.

double price = [[[transactionsArray objectAtIndex:indexPath.row] objectForKey:@"price"] doubleValue];
double accum = [[[transactionsArray objectAtIndex:indexPath.row] objectForKey:@"accum"] doubleValue];

I've tried doubleForKey instead of objectForKey, but the compiler doesn't like that and DoubleValue but that doesn't work either.

Help?

+2  A: 

You'll need to store your doubles as NSNumber instances e.g.

[NSNumber numberWithDouble:somevalue];
Mr. Matt
Yep, just like this: `[arrayTmp addObject:[NSDictionary dictionaryWithObjectsAndKeys:...[NSNumber numberWithDouble:price], @"price" ...]` and to get value from dictionary: `double price = [[[arrayTmp objectAtIndex:...] objectForKey:@"price"] doubleValue];`
Richard J. Ross III
Do you mean when I add them to arrayTmp or when I extract them in cellForRowAtIndexPath ?
Jules
look @ my updated comment, it explains everything
Richard J. Ross III