advertisement

Article:
  Adding Spit and Polish to Your Cocoa App
Subject:   why have a delegate rather than merely a
Date:   2002-06-27 15:46:45
From:   psheldon
Maybe this doesn't mean much to a guy who developes alone, but something to someone in a work group coding? Maybe I am already in a work group, since I am "subscribing" to cocoa framework.


I think using delegates and proxies has a theme getting value from having a choice when something needs to be known.


The proxy stuff allows you to set connections before runtime when the actual object is known. Not having to know at compile time means a certain kind of hiding information or abstraction that allows me or my user to be creative in putting things together live and with choice at runtime.


I'm imagining that delegates mean someone else can work on that code and someone can write in interface builder the outline of connections to his work as a plan. This can mean some division of knowledge between people in working in parallel rather than force things to be known in time sequence.


Knowledge might be cost at time Apple built frameworks :


Main.m with NSApplication seems to be hanging around for command line I/O and unix pipelines. I've fooled with a unix program for all permutations with output to the terminal in project builder. I imagine I could do command line input as well in either the same window of project builder or terminal.


To override NSApplication with a subclass, I would have to inherit that function, NSApplication, and import the subclass into main.m. I never heard of inheriting functions, only methods.


Is NSApplication an object from a class? Inspector shows file's owner in mainmenu.nib has NSApplication as it's attribute. Does NSApplication do anything for itself? Yes, it has 13 actions. None of these are things we did in the column. For some reason, Apple decided to specify (where?) some methods as delegate methods of NSApplication that you'd wire up just as in this column. Maybe that keeps NSApplication from having unneeded bulk covering all possibilities of all programmers choices.


I am glad Mike gave all those examples and maybe they must suffice before I am even ready to hear a formal description of distinction of overrides from delegate actions. Maybe my struggles at writing questions will further burn in the knowledge of those examples, even if no answer is worthwhile now.


Sorry for this confused post. Hope someone can write better than me on it. Got to get to a meeting.