Skip navigation.
 
mlStill trying to refactor a category as a class
FROM : Paul Archibald
DATE : Fri Jun 13 21:16:02 2008

Comrades:

Geez, I am feeling totally wrapped around the axle here.

I have posted questions on this project a couple of times, and have 
gotten useful answers that allow me to continue. Sometimes I think I 
am heading deeper into the weeds, though. So, let me try rephrasing 
my situation and try to ask a more specific question. Maybe the 
answer will put me back on track.

The project I am working on is used to make and distribute copies of 
certain files. I am trying to add a module that will do some extra 
processing of the files, and then distributing copies of that new, 
processed file. I was given the interface (a window with a bunch of 
popups and stuff) for the new module in the NIB, and there was 
originally a category (AppController(ExtraCategory)) for the extra 
"module".

Some of the functionality of the original copy code would be handy to 
reuse, but there are code dependencies in there that I don't want to 
touch, so I am planning to replicate the copy code and modify it for 
the new module. Not very OOP-sy, but what the heck, sometimes you 
just can't do things the way you would like.

I tried making a new controller for the new window/module, on the 
theory that since they don't share much data or functionality, they 
ought to be separate class objects. However, I am had some problems 
with that approach. In particular, I was getting several runtime 
errors of the type: "Could not connect the action 
someNSApplicationAction: to target of class MyController". I don't 
understand this at all, but I am more worried that I am just 
completely off track in trying to create a new controller, and that 
fixing this problem will just allow me to go even farther into the 
weeds.

So, here is my question:

Given my description of this project, does the two controller 
solution sound like the best one? Does anyone have any tips on how to 
re-factor this thing? My first effort kind of blew up in my face. I 
could not figure out how to do it gradually, so I just did a major 
cut/copy/paste/change-some-connections/rename-some-stuff kind of 
thing, and then built and ran it, but I don't know enough about the 
Cocoa/ObjC/IB/Xcode system to figure out what went wrong.

(And, a followup question would be: where could I find an example of 
an app that has multiple controllers which do not relate to the same 
document? The samples I have looked at so far seem to be based on the 
MCV pattern. I am looking for something more like MCV(1)+MCV(2).)

Paul

Related mailsAuthorDate
mlStill trying to refactor a category as a class Paul Archibald Jun 13, 21:16
mlRe: Still trying to refactor a category as a class Jack Repenning Jun 13, 22:12
mlRe: Still trying to refactor a category as a class Ken Thomases Jun 14, 03:19
mlRe: Still trying to refactor a category as a class Paul Archibald Jun 16, 03:16