Tools: MacApp
Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

Frequently Asked Questions

Answers to Questions Asked About MacApp


Okay, I've built both the debug version and the non-debug version of my application (or one of the standard MacApp examples) and the debug version starts up just fine but the non-debug version crashes. Aaarghhh! What's going on?


Chances are that the problem is related to a compiler problem during optimization of the code. Optimization is turned off for the debug versions of the ACS and MacApp libraries and the examples; optimization could be set as high as 'Level 4' for the non-debug versions.

The first thing we recommend is that you set the optimization level down to a lower setting for all projects involved in building your application (i.e. ACS, MacApp and your own project) then rebuild and see if the problem goes away. If the problem still occurs then keep trying lower optimization settings until optimizations are off.

Setting the compiler optimization is done in CodeWarrior Pro by bringing up the project's Settings dialog, selecting the Code Generation:Global Optimizations panel, and dragging the optimization slider to the left.


While linking in CodeWarrior I get the following error:

Link Error : missing vtable 'someClassName::__vt'
Check that all virtual functions and static members are defined

I've checked to make sure all of the functions are defined for someClassName and they are. I'm at a loss. What is the problem?


Check to see if you have used the MacApp macro 'MA_DECLARE_CLONE;' or 'MA_DECLARE_CLASS;' in your someClassName class definition but forgotten to include the corresponding 'MA_DEFINE_CLONE(someClassName);' or 'MA_DEFINE_CLONE(someClassName);' macro usage in your implementation file.


I've created my own view class which I am using in the resource file which defines my various windows. During runtime when the window is created using the NewTemplateWindow function it complains that it cannot find the class for my custom view class. What am I doing wrong?


Check to see that you have used the 'MA_DECLARE_CLASS;' macro in your view class definition and the corresponding 'MA_DEFINE_CLASS(someViewClassName);' macro in the implementation file. MA_DECLARE_CLASS is the macro which registers the class by name with the RTTI system so that the NewTemplateWindow function can find it when the class is being read in and instantiated.

Also, the MA_DECLARE_CLASS macro should be used for ALL classes which can be instantiated by name (i.e. by streaming them in from a resource file) including adorners, behaviors, and drawing environments.


I can't seem to be able to add my view resource file, created with Ad Lib, to my CodeWarrior project. If I change the file type from 'alib' to 'rsrc' then I can add the file but then Ad Lib isn't opened automatically when I double-click on the file.


Easy fix: using CodeWarrior, go into the project settings window (found below the Preferences menu item in the Edit menu), select File Mappings in the Target Settings Panels pane, and look in the File Mappings list shown on the right side of the window to see if there is a File Type of alib. If that file mapping does not appear in the list then you will need to add it.

Add the file mapping for Ad Lib files by clicking on the Choose… button then navigating to and selecting your view file. Select the Resource File and Launchable options in the Flags popup. If an extension is showing in the Extensions field we recommend that you remove it so that all Ad Lib files can be added, not just ones with that extension. Finally, click the Add button. You should now be able to drag Ad Lib view files into your project.

If an Ad Lib file mapping (alib) shows in the File Type list then you will want to check the Extension field. If an extension shows in this field it must match the one used for your file.


I've created a custom view in Ad Lib. How do I add it to my view palette and make a clipping of it?


An Ad Lib clipping is created using the following steps:

  1. Open up a new Ad Lib document.
  2. Create a new window.
  3. Create one of your new custom views on the window.
  4. Set up the view according to your desires.
  5. Drag this view to the desktop.
  6. Name the clipping file so you will remember what it is.

You can also drag this view to one of your palettes and give it a custom name and icon. Use steps 1-4 as given above, then:

  1. Drag this view to the desired object palette in Ad Lib.
  2. Click on the 'untitled' name and type the desired name.
  3. Find or make a clipping with a PICT in it of the desired icon for the view.
  4. Drag this clipping onto the default icon of the view in the palette. (This is a little tricky since the palette doesn't appear unless Ad Lib is active.)

Sometimes making a PICT clipping for use as a custom icon for a custom Ad Lib palette object can be a bit tricky using a paint program which doesn't support drag and drop. Any suggestions?


To create a custom PICT clipping for use with custom palette objects in Ad Lib try the following:

  1. Create the desired icon using your paint program.
  2. Select it using the lasso tool, if available, otherwise use some other tool.
  3. Copy.
  4. Activate the Scrapbook.
  5. Paste. The icon should appear in the scrapbook.
  6. Drag from the Scrapbook onto the Desktop. You now have a 'PICT' clipping which can be used as an icon for a custom object in a palette.

For what kinds of things in Ad Lib can a custom object be created and added to an object palette?


You can create clippings and custom objects for views, behaviors, adorners, text styles and drawing environments.


I have a document that gets changed when it is opened because the document contains an alias to a file that has been moved and the alias gets updated (and, yes, my code notifies the user that the alias has changed).

TFileBasedDocument::ReadDocument, though, resets the change count to zero after the document's file is read. This means that the user is never asked to save the changed document when it is closed (thus the updated alias is lost). What is the proper technique for insuring that the user is asked to save the document's changes in this situation?


Post a simple command at the point where your document reading code recognizes that the document has been changed (right next to that brilliant code of yours which notifies the user that the alias has changed). Use code such as:

gDispatcher->PostCommand(new TCommand(cNoCommand, this, kCantUndo, kCausesChange, this));

This will post a command to the command queue which in effect defers the changing of the document until a time subsequent to the completion of the current in-process document opening command.


What can be a co-handler?


Perhaps the question ought to be, "What cannot be a co-handler?" That's an easier question to answer: Do not install anything as a co-handler that is also installed in the target chain. This would include any document, window or view.

To give a document or view (or whatever) idle time make an idler object which is installed into the co-handler chain and which then passes on the idle time to the document or view through a custom function of your own design.

There are two examples in MacApp. TViewIdler is a behavior that gets added to the dispatcher, and gives idle time to a view. TIdler (in UStructureInspectors in DemoDialogs) is an event handler that adds itself to the co-handler chain and gives idle time to another event handler, such as a document.