Why does it work?


#1

Love the book. Haven’t put it down this weekend. But, this is one thing that drives me nuts about IB. I have absolutely no way of knowing what is going on sometimes.

I need help in understanding why two methods were called even though we didn’t assign it to anythin. I read about proxys. But still I didn’t hookup IB with insertObject:inEmployeesAtIndex:

Why does insertObject:inEmployeesAtIndex: and removeObjectFromEmployeesAtIndex get called?

Is it simply because those methods start with insert and remove? Is this overriding the insert or remove methods? If so, what happens later on if i wanted an insertLastNameObject?

I understand the Undo stuff, but this concept just blew my mind.


#2

The last paragraph on page 150 and first paragraph on page 152 provide clues, but you will have to read Apple’s documentation on Controllers to fully understand why that’s happening.


#3

No, I read that part. And that is what is throwing me for a loop. I just connected the insert and remove buttons to a respective insert and remove method in the ArrayController. At no time did I connect the methods we wrote up.

Can you give a TL;DR version of the magic that’s happening? Or Explain like I am 5? Or I don’t mind reading if you can point me directly to the document that would explain it.


#4

To cut a long story short, the array controller deduces those method names from the name of the object (employees array) it is bound to. That’s why they seem to be magically called, but there is no magic involved at all (It is all based on Objective-C method selectors plus Cocoa naming conventions and rules for accessing containers.)


#5

This is why I do not like Interface Builder. It creates these connections to method by itself.

Do you have a link to the document that talks about what you are talking about? I want to read it about it more.


#6

Does anyone know where I can find some docs from apple where this is documentated. I can’t find anything about that.

EDIT: Ok, I think I finally found it:
developer.apple.com/library/ios … tions.html