How to use accessors within the same class in Objective C?

Posted by Azeworai on Stack Overflow See other posts from Stack Overflow or by Azeworai
Published on 2010-06-14T22:13:16Z Indexed on 2010/06/14 22:22 UTC
Read the original article Hit count: 197

Filed under:
|
|

Hi, I have a few properties defined in my header file like so

@property (assign) bool connectivity_N;
@property (assign) bool isConnected_N;

In my implementation file I have an init and the synthesized properties like so

@implementation Map
@synthesize connectivity_N;
@synthesize isConnected_N;

a init to set the initial values like so

-(id) init
{
    if( (self=[super init]) ) 
    {

        //initialise default properties
        self.connectivity_N=NO;
            self.isConnected_N=NO;
    }
    return self;
}

I'm running into an error that states Error: accessing unknown 'connectivity_N' class method. In this public method within the class

+(bool) isConnectable:(directions) theDirection{

    bool isTheDirectionConnectable= NO;
    switch (theDirection) {
        case north:
            isTheDirectionConnectable= self.connectivity_N;
            break;

I'm not sure why is this so as I'm trying to grab the value of the property. According to the apple developer documentation "The default names for the getter and setter methods associated with a property are propertyName and setPropertyName: respectively—for example, given a property “foo”, the accessors would be foo and setFoo:"

That has given me a clue that I've done something wrong here, I'm fairly new to objective C so would appreciate anyone who spends the time to explain this to me.

Thanks!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c