aaazalea
aaazalea

Reputation: 7930

Errors whenever I access a property

I have a class JWGeoGame with these properties:

@interface JWGeoGame : NSObject{
    JWCountry *hidden,*last,*prev;
}
@property (nonatomic) JWCountry *hidden;
@property (nonatomic) JWCountry *last;
@property (nonatomic) JWCountry *prev;

//some methods

@end

Whenever I try to set any of them, however, I get a cryptic error:

Implicit conversion of Objective-C pointer type 'Class' to C pointer type 'struct objc_class *' requires a bridged cast.

This error occurs in ech of the following scenarios:

self.prev=self.last;
self.prev=nil;

When I try to use them for comparisons:

if (guess == self.hidden)
    return FOUND;

I get another error:

Member reference type 'struct objc_class *' is a pointer, did you mean ->?

but I get this error when I try -> instead:

Member reference base type 'Class' is not a structure of union.

Clearly, I'm doing something wrong here, but I can't figure out what, no matter how many examples I look at. How can I fix this?

EDIT:

JWCountry is currently just a skeleton:

@interface JWCountry : NSObject{
    NSInteger index;
}
@property NSInteger index;
@end

Upvotes: 1

Views: 441

Answers (1)

Carl Veazey
Carl Veazey

Reputation: 18363

You're possibly using dot syntax to get at properties from a class method, but self inside a class method is the actual class object itself, not an instance of the class, and hence doesn't have those properties.

To fix it, make sure that you only access properties of self in instance methods. If you need something like class level storage, use static variables.

Upvotes: 3

Related Questions