iphoneobjective-ccocoa-touchuikitnsenumerator

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


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)


Solution

  • 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.