tags:

views:

44

answers:

1

I've got a simple array of objects..

NSEnumerator * enumerator = [someArray.childItems objectEnumerator];
ChildItem* childItem;
while(childItem = [enumerator nextObject])
{
        someArray.total = someArray.total + childItem.SomeAverage;
}

someArray.total is a float, so is childItem.SomeAverage. When I try to compile, I get:

invalid operands to binary + (have 'float *' and 'float *')

What does this mean? Thanks in advance

A: 

It means your arguments are both float *, not float, and you can't add pointers together like that. :) (You can subtract pointers, though, but that's a different discussion unless you want to get into it.) You haven't shown the declarations so hard to say more.

P.S. You don't need to use that enumerator syntax in "modern" Obj-C (2.0). You can write:

for (ChildItem * childItem in someArray.childItems) {
    ...
}
quixoto
I think you mean ObjC 2.0 (modern may be confusing because it's usually referring to the runtime, and you can use objc 2.0 on both modern and legacy runtimes). Also you need to use the 'for' keyword here, not while.
Jason Coco
corrected typo, thanks.
quixoto