• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
re-factoring a category into a class instance
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re-factoring a category into a class instance


  • Subject: re-factoring a category into a class instance
  • From: Paul Archibald <email@hidden>
  • Date: Tue, 10 Jun 2008 14:05:25 -0700

Comrades:

I am working on a file-handling Cocoa app that (at this point) has a single window. We are adding a second window (really sort of a non- modal dialog) to do some extra processing of the target files. The interface for the new window is already built (with IB), but is not hooked up yet.

So, the way this started was as a AppController(ExtraCategory) thing, with the NIB file having a single controller object. I don't like that method, because there is a lot of data and code that would need to be replicated in the main AppController to handle the work that the ExtraCategory does. What I would like to do is put all the ExtraCategory stuff into its own class, but I am not sure how. My inclination is toward making the ExtraCategory into a NSWindowResponder, but the documentation I have read so far makes it look like that is more intended for document-based apps, which this is not. Also, I don't quite see (looking at some example code) how an extra controller is instantiated by the main app controller.

< A simplified example of the current code >

@interface AppController {
	NSString* srcDir;	// the original stuff
	NSString destDir;	// original
	// there is a bunch more

NSString* srcDirForExtraCategory; // needed for new window/dialog/ category
NSString destDirForExtraCategory; // needed for new
// more stuff needed here
}
-(void)setSrc; // implemented in the .m file, of course
-(void)setDest;
@end


<and in AppController(ExtraCtegory)>

@interface AppController(ExtraCategory)
-(void)setSrcForExtraCategory;	// special handling
-(void)setDestForExtraCategory;	// special handling
@end

It seems funky to me that I can declare extra functions for the ExtraCategory, but I can't add member data. I understand there is a difference between the class/subclass and the class/category paradigms. I guess what I am trying to do is turn this new window category into a standalone class, instantiate it (in the NIB, I suppose), and control its availability from the original main app controller instance.

Any advice?
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: re-factoring a category into a class instance
      • From: Brian Stern <email@hidden>
  • Prev by Date: Re: Prevent Asynchronous operation of beginSheetModalForWindow
  • Next by Date: Re: Mail Rule Actions Control
  • Previous by thread: Re: Mail Rule Actions Control
  • Next by thread: Re: re-factoring a category into a class instance
  • Index(es):
    • Date
    • Thread