Reputation: 310
I have an array with photos and I want to display them on UITableView
, the cell of the UITableView
contain 4 UIImageView
, so i want calculate the number of rows that will be contain the UITableView
. lets say if have 5 photos I must divide 4 and gives 2 but the problem is when i divide this number it gives a long Double so I can't get the ceil of this number. this my code:
NSLog(@"%Lf", ceill([imageArray count] / 4));
In the console it gives that:
==> nan
Upvotes: 1
Views: 115
Reputation: 106167
This:
NSLog(@"%Lf",cei, ceill([imageArray count] / 4));
simply prints whatever the value of cei
is (assuming cei
is a long double; otherwise the result is undefined). You want:
NSLog(@"%Lf", ceill([imageArray count] / 4));
That said, is [imageArray count]
really a long double
, or is it long
(an integer type)? If the latter, don't use ceill
; instead use:
NSLog(@"%ld", ([imageArray count] + 3)/4);
Upvotes: 3