IPhone, How to get double from my NSDictionary Array?

Here is my array

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

I fill it this way

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];

What in my h file is NSMutableArray

    NSMutableArray *transactionsArray;

Now in my CellForRowAtIndexPath I can call strings, but I cannot pull out doubles.

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

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

reference

+3
source share
1 answer

You will need to store your doubles as instances of NSNumber, for example.

[NSNumber numberWithDouble:somevalue];
+9
source

Source: https://habr.com/ru/post/1767170/


All Articles