Why doesn't NSEnumerator iterator recognize object properties within DrawRect?

393 Views Asked by At

I usually have no problems using NSEnumerator in the iPhone sdk but this is my first time using it within the DrawRect function of a UIView. The NSEnumerator iterator is causing an error: request for member "(member)" in something not a structure or union.

1) Why is this happening?
2) How can I workaround it?

(P.S. the member not being recognized is a properly declared and synthesized property of an NSObject Subclass whose .h file is properly imported in the UIView .m file whose drawRect function calls the NSEnumerator)

2

There are 2 best solutions below

1
On BEST ANSWER

It's hard to say without seeing the code. But typically the compiler issues that error when you have something like this:

@interface MyClass : NSObject {
  int someValue;
}
@end

.... and then in implementation....

MyClass *aPointer;

int index = aPointer.someValue;

In this case, you'd actually want

int index = aPointer->someValue;

Obviously the syntax differs a little for properties. You assert that the property is properly declared and synthesized, but obviously the compiler disagrees. I'm not sure how much help anyone can give you without seeing some code excerpts, though. It's extremely unlikely that NSEnumerator itself is not recognizing your member. Rather, some code you wrote in the context of that iterator has a typo.

1
On

The other thing to remember is that NSEnumerator returns ids, not object pointers (unless you're casting them). An id has no properties, so ANY attempt to access a property on an id will fail. As peterb said, seeing code will help a lot here.