Hi,


suppose I have a class with a private member as listed at the end of this email.

Then I can access it by calling its name without an accessor function (which would de facto make it public).

But how do I access a private member of another object of the same class?


Or does Objective C have another concept of "private" than C/C++ ?


Thanks in advance

Horst


::::::::::::::::::::::::

PrivateClass.h

::::::::::::::::::::::::

@interface PrivateClass : NSObject {

        @private int mineAlone;

}

-(int)yoursToo;
-(int)yoursTooButWithAnother: (PrivateClass *)another;


@end

::::::::::::::::::::::::

 PrivateClass.m

::::::::::::::::::::::::

#import "Private.h"


@implementation PrivateClass

-(int)yoursToo{

        // access via name works

        return mineAlone % 3;

        // I cant't use
        // return [self mineAlone]
        // using a getter function
        // because that would make
        // mineAlone accessible for
        // everyone since a method
        // can't be declared private

}

-(int)yoursTooButWithAnother: (PrivateClass *)another;

        // what am I to do?
        // return another.mineAlone % 3;
        // won't work and
        // return [another mineAlone] % 3;
        // would de facto make it public

}

@end

::::::::::::::::::::::::



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to