I am struggling to understand some basic concepts in Objective C, would appreciate if someone can help. This is about accessors - setters and getters. I have Cocoa application with the following classes:

I guess the issue I have should be understandable from what I am trying to do in Another.m someMethod. In summary:

- Theres NSTextView *drawerText defined in AppDelegate
- drawerText is an IBOutlet which is properly linked in IB
- I need to display some content in drawerText and the content should come from Another.m class
- When I run someMethod nothing is displayed in drawerText
- when I NSLog drawerText from Another.m it has ABC value
- when I NSLog drawerText from AppDelegate.m it is empty, though not (null)
- when I run the same someMethod from within AppDelegate.m, everything work, i.e. ABC is displayed in drawerText

As I said, I believe I am missing some basic understanding here, as the issue is not only with this particular drawerText but with any control or instance variable defined in one class and set / get from another class.

I read a lot of Objective C docs by Apple, various books (Stephen G. Kochan, SCOTT KNASTER, MARK DALRYMPLE) but I just can't grasp how to use setters and getters across different classes.

I do not have any programming background, Objective C is my first language. Usually, if there is enough time, I can figure out things, but not this time. By reading these books, I even managed to developed couple of simple Cocoa Apps, but had to keep everything in one class, which obviously is not correct, especially when an app becomes more or less complex.

This will get you every time. I'm not sure you're making the object vs. class differentiation. There is an AppDelegate object created that has sone state. It is an instance of the AppDelegate class. You create another instance by passing "new", manipulate it, and hope that the other AppDelegate object reflects these changes. "new" is outmodded and you can forget about it. In your Another class you will need a way to access the AppDelegate object that is in use, rather than creating a new one. Look at sharedApplication on UI/NSApplication, then pass delegate to the resulting object.

See if there are programming courses at a community college nearby or watch some iTunes U courses. I'd go for the prior, because it would benefit you to be able to bounce things off of classmates and instructors.

This will get you *the* delegate for *the* NSApplication, instead of creating a new one. Gnasher was implying that you would leak the object you created, but you shouldn't create one in the first place.

This will get you *the* delegate for *the* NSApplication, instead of creating a new one. Gnasher was implying that you would leak the object you created, but you shouldn't create one in the first place.

I do not have any programming background, Objective C is my first language.

This was me almost 3 years ago. I struggled and found what I could in books and online to make things work without grasping the basics. The people helping you now are the same folks that helped me understand the basics years ago.

I finally stopped struggling and went back to the basics, learned C first. When I understood the basics of programming and made some small programs stepping in to Objective C was much easier and I understood it the second time around.

If you want to be a successful at programming start in the right area. Even if you get the answer to your question and it works, you won't understand why it works which will just lead to bigger problems down the road for you. At that point you will just give up trying to program thinking it is to hard. When really you just started in the wrong place.

This was me almost 3 years ago. I struggled and found what I could in books and online to make things work without grasping the basics. The people helping you now are the same folks that helped me understand the basics years ago.

I finally stopped struggling and went back to the basics, learned C first. When I understood the basics of programming and made some small programs stepping in to Objective C was much easier and I understood it the second time around.

If you want to be a successful at programming start in the right area. Even if you get the answer to your question and it works, you won't understand why it works which will just lead to bigger problems down the road for you. At that point you will just give up trying to program thinking it is to hard. When really you just started in the wrong place.

and might I recommend the book "Learn C on the Mac". Other people have their favorite books too they recommend. Forget about pretty interfaces, buttons, textfields and so on. Read it till it sinks in and create your own projects from every chapter till it sinks in.

I spent about 3 to 4 months with that book and moved on when I could write my own command line blackjack program from scratch. It was ugly looking code wise but it worked!