in my appDelegate and give it the "Employee" that's selected, thus the instance has an employee to work with. I know for sure, it gets the given employee, because NSLog always prints it out correctly.
The NSTextField called "mikk" is correctly linked in IB, cause it sets the labels text to "hello" in the awakeFromNib method. So the main problem is: why I can't set the labels text elsewhere?

I know this looks weird/stupid, but please let me know, if you'd like any more information (also what, if you can be more specific) and suggestions to make this text more readable.

Edit: Looked over the code and left only the "i-think-important-bits" in. Also retained the IBOutlet without any effect on the goal.

@Caleb, sorry for leaving unnecessary stuff there, I was just too tired yesterday. And @Bavarious, I have connected the view in IB with the NSViewController (that's using custom class of EmployeeView). Should I make an Outlet for it in code also?
–
Mikk RätsepJun 17 '11 at 13:09

NSViewController already declares a view outlet, which you’ve said you’ve already connected. (For the record, @ in comments notifies only the first user; in your comment, it notified Caleb but didn’t notify me.)
–
BavariousJun 17 '11 at 13:54

2 Answers
2

Are you using garbage collection? Here's what the docs on nib loading say about object retention under garbage collection:

Most objects in the graph are kept in
memory through strong references
between the objects. Only the
top-level objects in the nib file do
not have strong references initially.
Thus, your code must create strong
references to these objects to prevent
the object graph from being released.

So, if you don't have a strong reference to the top-level object that contains your text view, probably a view or window, the entire object graph is probably being collected.

I am using garbage collection. If it changes anything, I have created an instance in my appDelegate of the EmployeeView and am using it there to call for it when needed.
–
Mikk RätsepJun 17 '11 at 12:38

Presumably EmployeeView is the view that contains the label in question? Are you creating it by loading it from the nib? Whatever the details, if you're calling -setSelectedEmployee: and the label that mikk points to doesn't change, then it seems likely that mikk is pointing to the wrong thing, or to nothing at all. Try looking at the value of the pointer in -awakeFromNib and then again in -setSelectedEmployee:. If it changes, then mikk is somehow being modified. If it doesn't, then the memory it points to is probably changing, deallocated, etc.
–
CalebJun 17 '11 at 14:18

1

@Caleb, Yes, Yes, I added breakpoints to those methods and saw that on the second time it calls -awakeFromNib (the program calles it twice, is that ok?) the mikk is pointing to 0x0 (on the first call it had a valid memory address) and it stays 0x0 through the program.
–
Mikk RätsepJun 18 '11 at 11:01

@Mikk, if mikk is 0x0 (i.e. nil), then you probably forgot to connect it to a text field in you nib. I know you said its value is set to 'hello', but wondering if you didn't set that up in the nib as well? Also, if -awakeFromNib is called twice on the same class, it probably means that you're instantiating the class twice, which is not likely what you want in this case.
–
CalebJun 18 '11 at 12:35

@Caleb, it's connected correctly in the nib, and changes it in the runtime (in nib it's title is "Label"), but I guess the underlying problem I have here, is that I make another instance of the class. Thanks for helping me to get to the right path.
–
Mikk RätsepJun 18 '11 at 15:29

@Bavarious, see my answer below. "collected" is probably a better word than "released," but I'm usually in an iOS mindset so I default to thinking in terms of retain/release.
–
CalebJun 17 '11 at 12:30