• 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: Could not connect the action to target of class
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Could not connect the action to target of class


  • Subject: Re: Could not connect the action to target of class
  • From: Hamish Allan <email@hidden>
  • Date: Sat, 12 Mar 2005 13:23:39 +0000


On Mar 11, 2005, at 22:13, Sherm Pendley wrote:

Unless you have a specific reason for needing a separate controller, don't create one. Just delete it, delete the myController outlet, and put your action methods in your document class.

Well, perhaps I'm over-engineering my program's architecture. I'll give you a brief description of what I'm doing and perhaps you can advise me on my MVC breakdown.


I'm writing an app for editing ID3v2 ETCO (Event Timing COdes) in MP3 files. The document window has a custom view displaying the amplitude envelope of the audio data, a slider to change the zoom level, and a play/pause button. The custom view also displays various vertical lines: a cursor at the editing position, one at the playback position, and any number of event onsets, which can be added at either of the cursors (e.g., by pressing a key whilst the audio is playing) and dragged around using the mouse.

I have an NSDocument subclass as my model-controller which takes care of the audio data, including loading and saving audio and tags to and from the MP3 file. Then I also have an NSWindowController subclass as a view-controller because it seemed wrong for my NSDocument subclass to be handling things like 'play' (which involves all sorts of non-model related things like callbacks from the audio player to update the position of the playback cursor).

If you're working with a complex app that needs multiple window controllers, or a subclass of NSWindowController, override -makeWindowControllers in your document class and create the controllers there.

I don't need multiple window controllers, but would you agree with me that I need a view-controller?


It seems to me that it's my view-controller that wants access to all these GUI elements, so if I instantiate it programmatically I'm going to have to pass it all the IBOutlets from my NSDocument subclass, which then has no further use for them. This seems wrong, which is why I want to instantiate it in IB and connect it all up there.

If you need to initialize GUI elements or other outlets you've connected in IB, you can't do that in -makeWindowControllers; the Nib hasn't yet been loaded at that point. Instead, do that in your document class' -windowControllerDidLoadNib: method.

So is it not possible to instantiate and connect view-controllers from within IB at all?


Many thanks for your advice,
Hamish

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Could not connect the action to target of class
      • From: Sherm Pendley <email@hidden>
References: 
 >Re: Could not connect the action to target of class (From: James McConnell <email@hidden>)
 >Re: Could not connect the action to target of class (From: Sherm Pendley <email@hidden>)
 >Re: Could not connect the action to target of class (From: Hamish Allan <email@hidden>)
 >Re: Could not connect the action to target of class (From: Sherm Pendley <email@hidden>)

  • Prev by Date: Re: newbie - multiply error
  • Next by Date: Add menu items to Dock
  • Previous by thread: Re: Could not connect the action to target of class
  • Next by thread: Re: Could not connect the action to target of class
  • Index(es):
    • Date
    • Thread