views:

40

answers:

1

I am in the process of cleaning my code and testing for bugs, when I came across this build error: ['xmlEntity' is not an Objective-C class name or alias]. Here is a shorten version of my class .h file.

@interface PMXMLParser : NSXMLParser {
           NSMutableDictionary *xmlEntity;
           NSMutableDictionary *collectionDict;
}
@property (nonatomic, retain)   NSMutableDictionary *xmlEntity;
@property (nonatomic, retain)   NSMutableDictionary *collectionDict;

@end

Here is the .m file.

@implementation PMXMLParser

@synthesize xmlEntity, collectionDict

- (void) dealloc
{
    // this builds correctly, with no issues.
    [collectionDict release];


    // 1. This works
    //self.xmlEntity = nil;

    // 2. This causes the build error: 'xmlEntity' is not an Objective-C class name or alias
    //[xmlEntity release];

    [super dealloc];
}
@end

Now to me these example 1 and 2 do the same thing, just with a little bit more work is done for number 1.

Does anyone know why I am getting this build error for number 2?

Edit: 07/30/2010 - The code presented here will compile correctly, this is just a shorten version of my whole class. But my current class does not compile. I will post the whole class later when I taken out private code.

Thanks.

+1  A: 

Is that really your implementation? You need to have a separate @implementation section in a ".m" source file, and you need to @synthesize those properties before you can use them. Also, your dealloc function needs to go in the @implementation section. But, those issues aside, if you can use the expression self.xmlEntity but not xmlEntity it means there is a scoping issue (probably because you aren't in the @implementation section) which can be fixed by using:

[self.xmlEntity release];

That said, I would address the aforementioned issues properly.

Michael Aaron Safyan
You already get compilation errors when putting method definitions outside of `@implementation` sections.
Georg Fritzsche
[self.xmlEntity release] does compile. My confusion is why must I do that. Once that can be figured out I will consider this problem solved.
evanchri