PDA

View Full Version : accessing unknown 'myvar' component of a property




skunkio
May 6, 2010, 02:43 PM
Hi all,
i'm getting this error during the build of my app following the code below.
I have 3 classes:

ClassA (UIViewController)
ClassB (UIViewController)
ClassC (NSObject)

Inside ClassA i have a property defined as ClassB.


@property (nonatomic, retain) ClassB *B;


ClassB has a property defined as ClassC.


@property (nonatomic, retain) ClassC *C;


ClassC ha some properties inside


@property (nonatomic, retain) NSString *Prop1;
@property (nonatomic, retain) NSString *Prop2;


The error is inside ClassA on the line:

txtTest.text = self.ClassB.ClassC.Prop1;

in this same class i initialize ClassB as per follow code

self.B = [[ClassB alloc] init];

How can i use ClassC properties whitin ClassB?

Ciao,
stè



dejo
May 6, 2010, 02:47 PM
How can i use ClassC properties whitin ClassB?

Start by not referencing your ivars by their class names.

Perhaps it is time for you to step back from the real coding and go (re)learn the basics of Objective-C.

skunkio
May 6, 2010, 04:34 PM
Start by not referencing your ivars by their class names.

Perhaps it is time for you to step back from the real coding and go (re)learn the basics of Objective-C.

I'm pretty new with objective-c, maybe there is more than one thing i have to re(learn).
Which section, basics of Objective-C, you think i have to investigate to understand what i'm doing wrong?

Ciao,
stè

dejo
May 6, 2010, 04:48 PM
Which section, basics of Objective-C, you think i have to investigate to understand what i'm doing wrong?
I would suggest not thinking of it in terms of what you have to learn to fix what's wrong but instead what you need to learn to gain a basic understanding of the language and how to use it. Put away any real code you are working on. Get a book or take some tutorials or watch some videos and start coding from the ground up.