Harsh Harsh - 11 months ago 79
iOS Question

Getting an error while adding a integer to array object at index (objective c)

while adding a integer to object at index of an array, I am getting an error of "arithmetic on pointer to interface id which is not a constant size for this architecture and platform", didn't know how to resolve it.
Please help.

my code is -

if (arrayTotalAmount.count>0) {
int sum = 0;
for (int i = 0; i<=arrayTotalAmount.count; i++) {
sum = (sum+[arrayTotalAmount objectAtIndex:i]);

}


In 4th line I am getting that error.
Thanks

Answer Source

You just need to convert your array object to integer and then add it will work for you.

if (arrayTotalAmount.count>0) {
                     int sum = 0;
                    for (int i = 0; i<=arrayTotalAmount.count; i++) {
                     sum = (sum+[[arrayTotalAmount objectAtIndex:i] intValue]);

    }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download