Re: Apple Help question

2008-02-29 Thread Matt Neuburg
On Wed, 27 Feb 2008 12:12:57 -0500 (EST), "z" <[EMAIL PROTECTED]> said:
>
>I have problems trying to implement Apple Help.
>All I get is an empty help window without a title.
>
>My index.html file is:
> 
>My Info.plist includes:
> CFBundleHelpBookName
> Yellow Help Book

Blp! Mismatch, did not follow directions, game over, thank you for
playing! :) m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: How to interrupt a long loop with command-period?

2008-03-30 Thread Matt Neuburg
On Sat, 29 Mar 2008 20:45:38 -0400, Duncan Champney <[EMAIL PROTECTED]> said:
>My app can create 3D views of the fractal images it creates.
>
>It has an option to save very large versions of these 3D views to disk
>as JPEGs or TIFFs. I generate the images as tiles, then assemble them
>and save the result to disk. For very large images this can take tens
>of seconds.
>
>I have a save panel that I display as a sheet on my 3D view, and I'm
>showing a progress bar on the save panel as I build the image for
>saving. My code has to call [progress_bar display] explicitly, since I
>don't visit the event loop while I'm generating my image.
>
>I'd like to be able to have the user press command-period/escape and
>quit the save in the middle.
>
>I thought I could check for key down events with a call like this:
>
>theEvent =  [[self window]
nextEventMatchingMask:(NSKeyDownMask)];
>
>But when I issue that call, everything comes to a halt until the user
>presses a key.
>
>I really want a "check the event queue for keyboard events" call that
>would let me pick command period or escape key events out of the
>applications event queue.
>
>I don't want to re-factor my code to return to the event loop if I can
>help it, both because it would be a fair amount of work, and because
>I'm using the OpenGL back buffer for my window to do my tiled
>rendering, and if the user makes changes to the window it would mess
>up my off-screen rendering. If I do have to re-factor my code to
>service the event loop I'll have to tear down the save panel sheet
>only to draw another save progress sheet in it's place, both as a
>place to show a progress bar, and to keep the user from messing up the
>save that's in progress. At least if I did that I could put a cancel
>button on it and be able to respond when the user clicks it.

I could be totally off base here, but what I do in this situation (and it
hasn't bitten me yet) is do the hard work in a thread. This leaves the main
event loop open. So, the user does whatever (press the Stop button, type Esc
or Command-period, etc.) and I hear about it immediately. I then raise a
flag (i.e. set a boolean). Meanwhile my hard-working code is periodically
checking that flag.

Now, there might be some reason why you can't do this (perhaps having to do
with your use of OpenGL), in which case just ignore that idea. m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Need for a creator code?

2008-04-04 Thread Matt Neuburg
On Thu, 03 Apr 2008 17:08:56 -0600, Scott Ribe <[EMAIL PROTECTED]>
said:
>> But having an app explicitly
>> and automatically mark documents it saves as opening in itself can get
>> frustrating for the user.
>
>How so? It seems the most reasonable default. I really don't see end users
>saving a file from one app, and expecting it to automatically open with a
>different app. In fact, that seems like it would be rather surprising
>behavior.

Indeed, the problem is that that is exactly what *does* happen, e.g. a .rb
file saved with TextMate opens when double-clicked with Xcode or Coda,
behavior that drives me insane. I wish TextMate *would* mark files it
creates as belonging to itself. Some apps (e.g. Script Debugger, which deals
in .scpt files that might also be opened by Script Editor) make this a pref;
that seems reasonable behavior. m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSAppleScript question

2008-06-04 Thread Matt Neuburg
On Wed, 4 Jun 2008 21:09:53 +1000, Matthew Delves <[EMAIL PROTECTED]>
said:
>Greetings and salutations,
>Is there a way to pass arguments into an AppleScript file using
>NSAppleScript and other cocoa/obj-c classes?
>
>The reason that I ask is I am wanting to find out the path to a song
>in iTunes. I have a script which does this for hard coded values,
>though am uncertain as to how to accomplish it (or if it is indeed
>possible) using NSAppleScript.

I think what you're asking to do is what I illustrate on pp. 478-9 of my
AppleScript book (though I can't quite be sure from the way you describe
it). Or you could just google on "executeAppleEvent" to find out more. m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: setFirstResponder to NSTextField fails 1st time, works next

2008-07-02 Thread Matt Neuburg
On Wed, 2 Jul 2008 00:20:53 -0400, Moses Hall <[EMAIL PROTECTED]> said:
>Hi folks,
>
>Here's a problem I'm having under Tiger, developing an LSUIElement
>application (Input Method server -- it's the UI for IPA Palette
>[www.blugs.com/IPA]). I have an NSTabView, one of whose panes has a
>search field which is an NSTextField subclass (note that the same
>problem occurs if I use an NSTextField). I want to make this field
>the first responder when the "Search" tab is chosen. Oddly, it does
>not become first responder the first time the pane is selected. It
>does not become key, and does not accept text (unless clicked on). If
>I move to a different tab and come back, then I get the desired
>result: the focus ring is there and I can type into the field.
>
>This is happening inside an NSPanel subclass...
>
>@implementation IPAPanel
>-(BOOL)canBecomeKeyWindow {return YES;}
>-(BOOL)canBecomeMainWindow {return NO;}
>-(void)awakeFromNib
>{
>   [self setHidesOnDeactivate:NO];
>   [self setBecomesKeyOnlyIfNeeded:YES];
>}
>@end
>
>Here is my tab switch delegate method:
>-(void)tabView:(NSTabView*)tv didSelectTabViewItem:(NSTabViewItem*)item
>{
>   NSLog(@"first responder WAS %@", [_window firstResponder]);
>   if ([[item identifier] isEqual:@"Search"])

What's the purpose of this test? Is it necessary? Is it working? Try putting
an NSLog inside the test to see whether it is passing/failing when you think
it should be.

>   {
> [_window makeKeyWindow];
> [_window makeFirstResponder:_searchText];
>   }
>   NSLog(@"first responder: %@", [_window firstResponder]);
>}

m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Method Sees Populated Array As Empty

2008-07-05 Thread Matt Neuburg
On Sat, 5 Jul 2008 22:36:07 +0100, Mark Wales <[EMAIL PROTECTED]>
said:
>Hello,
>
>I'm trying to get a document based app to save the contents of an
>array (NSMutableArray *arrayOfReferences) that is declared and
>initialised in the MyDocument.m. Whenever any method in MyDocument.m
>or other classes tries to access the arrayOfReferences it has no
>problems and everything works fine, except for when I use the
>
>- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
>
>method to save. I've put an NSLog("%@", arrayOfReferences) at the
>beginning of this method and the array comes out as empty, even though
>with every other method it is populated as it should be.

Perhaps you are not referring to the actual arrayOfReferences. I presume
arrayOfReferences is an ivar? Then maybe there is something wrong with your
accessors or your memory management. Use debugging or logging to check that
this is really the object you think it is. Since you don't show any code,
it's hard to say more. m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSAppleScript - compileAndReturnError always breaks with EXC_BAD_ACCESS

2008-07-05 Thread Matt Neuburg
On Sun, 6 Jul 2008 00:44:19 +0200, Alex Wied <[EMAIL PROTECTED]> said:
>Greetings,
>
>I have a trivial AppleScript that I would like to compile and run
>under Objective-C. When I try to compile or execute it via
>compileAndReturnError or executeAndReturnError I'm permanetly
>receiving a EXC_BAD_ACCESS.
>
>Here's my code:
>
>=== CODE START ===
>- (IBAction) simpleScript:(id)sender
>{
> NSAppleScript* theScript = [[NSAppleScript alloc] initWithSource:
>@"beep 3"];
> if (theScript != NULL)
> {
>  NSDictionary* errDict = NULL;
>  // execution of the following line ends with EXC
>  if (YES == [theScript compileAndReturnError: &errDict])
>  {
>   NSLog(@"compiled the script");
>   [theScript executeAndReturnError: &errDict];
>  }
>  [theScript release];
> }
>}
>=== CODE END ===

This probably won't help much, but I copied and pasted your code into Xcode
and it ran fine on every machine I've got... However, I don't have the
version of Xcode that you have which we're not allowed to mention. m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: controlling system muting ?

2008-07-08 Thread Matt Neuburg
On Mon, 07 Jul 2008 23:25:34 -0400, Jason Bobier <[EMAIL PROTECTED]> said:
>Hey folks,
>
>Has anyone figured out how to control a machine's volume level
>(specifically muting) from code? I know that you can do it from
>Applescript, but running an applescript from code seems to be a rather
>clunky approach.
>
>This is for emergency notification, so I have to be able to crank the
>volume on the system and then restore it afterwards.
>
>Thanks for any insight!
>
>Jason
>
>
>

Always worthwhile checking the archives before posting. The technique is
pretty well demonstrated here:

http://www.cocoabuilder.com/archive/message/cocoa/2008/3/12/201211

m.
-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: controlling system muting ?

2008-07-08 Thread Matt Neuburg
On or about 7/8/08 10:56 AM, thus spake "I. Savant"
<[EMAIL PROTECTED]>:

> AudioDeviceSetProperty() is of
> course more efficient but unless you're muting/unmuting the overall
> system volume fifty times per second, the user truly won't notice,
> therefore AppleScript will work **JUST FINE**. ;-)

But that isn't what the OP asked. The OP asks *how* to do it without
AppleScript - not *whether* to do it without AppleScript. Furthermore, the
OP is right that running an AppleScript from within Cocoa/Objective-C is
noticeably slower than going thru CoreAudio. m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, http://tinyurl.com/2ouo3b
Take Control of Customizing Leopard, http://tinyurl.com/2t9629
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Receive notifications about frontmost application change

2008-07-10 Thread Matt Neuburg
On Wed, 09 Jul 2008 17:47:23 -0400, Bill Cheeseman <[EMAIL PROTECTED]>
said:

>In Leopard, you can make your application process trusted by the
>accessibility API (requires user authentication), using the
>AXMakeProcessTrusted function. Then you don't need to ask your users to
>enable global access for assistive devices. However, making your process
>trusted is not easy -- you have to embed a couple of helper applications in
>your application package, one of them to run as root and make your process
>trusted, and the other to relaunch your application so the newly-trusted
>process is running. If you have an easier way to accomplish your goal, go
>for it.

Copy and paste is pretty easy:

http://www.cocoabuilder.com/archive/message/cocoa/2006/2/4/156003

m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Responder Chain Patching

2008-07-13 Thread Matt Neuburg
On Sun, 13 Jul 2008 16:48:45 +0100, Keith Duncan <[EMAIL PROTECTED]> said:
>I'm working with NSViewController to create a workflow of controllers.
>I'm trying to patch the controller into the responder chain so that I
>can implement action methods in the specific controllers and in the
>window controller.
>
>I'm using the following code in an attempt to create a responder chain
>like this:
>
>ButtonView -> ContainerView -> MyViewController -> WindowContentView -
> > Window -> WindowController -> etc...
>
>- (void)setViewController:(TLViewController *)controller {
> if (_viewController != controller) {
>  [_viewController release];
>  _viewController = [controller retain];
>  _viewController.controller = self;
>  
>  [self setActiveContentView:[_viewController view]];
>  
>  // Patch into the responder chain
>  // This must be done after the view has a superview
>  [_viewController setNextResponder:[[_viewController view]
>nextResponder]];
>  [[_viewController view] setNextResponder:_viewController];
> }
>}
>
>However, it isn't working. The view controller doesn't receive any
>messages

This might not be of any help, because I know nothing whatever about
NSViewController or why you'd want to insert one into the responder chain
(and whether that's okay or necessary to do). But I *am* a *huge* fan of
inserting stuff into the responder chain - it's something I do all the time.
And when I do it, I patch the chain in opposite order.

For example, in several of my apps I inject an NSResponder subclass instance
after an NSTableView (so, between the table view and the window - actually,
it's between the table view's containing scrollview and the window). And
here's how the code goes (I use awakeFromNib and keep an instance of my
NSResponder subclass in the nib, so that I am guaranteed of having just one
and of having everything hook up at the appropriate moment):

- (void) awakeFromNib {
NSResponder* r = [[myTableView enclosingScrollView] nextResponder];
[[myTableView enclosingScrollView] setNextResponder: self];
[self setNextResponder: r];
}

It might help or it might make no difference at all, but that's the kind of
thing that works for me... m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Custom NSCells

2008-07-13 Thread Matt Neuburg
On Mon, 14 Jul 2008 10:59:44 +1200, "Paul Williams" <[EMAIL PROTECTED]> said:
>Hi,
>
>I am trying to find a way where I can use a NSTableView to display a list of
>buttons(NSButtonCell) which can be hidden depending on the state of the
>program.
>I have tried using a custom NSCells, but the only object I can can pass to
>my custom cell is a NSCFBoolean.
>Is there a way I can pass more information to my custom cell so I can have a
>button which can be set to On,Off or hidden.

I think a typical approach is to implement
tableView:willDisplayCell:forTableColumn:row: in the table view's delegate.
m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSUserDefaultsController, when does value change?

2008-07-14 Thread Matt Neuburg
On Sun, 13 Jul 2008 21:29:56 -0700, "James W. Walker" <[EMAIL PROTECTED]>
said:
>I have a preferences dialog that I'm using with an
>NSUserDefaultsController instance, my first use of bindings, and it
>works.  But I want to post a notification when a certain setting
>changes.  In my method that shows the dialog, I record the old value
>of the setting.  In my action method for the OK button, I send a save
>message to the defaults controller  (the "applies immediately" option
>is off), send a synchronize message to the NSUserDefaults, then check
>the value of the setting and compare it to the old value.  But the
>value has not changed!  It obviously gets changed at some point,
>because the next time I bring up the dialog, the new value has is
>there.  What am I missing?

What you're doing is unnecessarily complicated. Just use KVO to observe the
desired value within the standardUserDefaults. You get a notification
contining the old value and the new value. Welcome to the world of bindings.
m. 

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSUserDefaultsController, when does value change?

2008-07-16 Thread Matt Neuburg
On Mon, 14 Jul 2008 19:36:29 -0700, "James W. Walker" <[EMAIL PROTECTED]>
said:
>
>On Jul 14, 2008, at 9:34 AM, Matt Neuburg wrote:
>
>> On Sun, 13 Jul 2008 21:29:56 -0700, "James W. Walker" <[EMAIL PROTECTED]
>> >
>> said:
>>> I have a preferences dialog that I'm using with an
>>> NSUserDefaultsController instance, my first use of bindings, and it
>>> works.  But I want to post a notification when a certain setting
>>> changes.  In my method that shows the dialog, I record the old value
>>> of the setting.  In my action method for the OK button, I send a save
>>> message to the defaults controller  (the "applies immediately" option
>>> is off), send a synchronize message to the NSUserDefaults, then check
>>> the value of the setting and compare it to the old value.  But the
>>> value has not changed!  It obviously gets changed at some point,
>>> because the next time I bring up the dialog, the new value has is
>>> there.  What am I missing?
>>
>> What you're doing is unnecessarily complicated. Just use KVO to
>> observe the
>> desired value within the standardUserDefaults. You get a notification
>> contining the old value and the new value. Welcome to the world of
>> bindings.
>
>
>I think I considered KVO, but I looked in the NSUserDefaults
>reference, and didn't see any indication that it conforms to
>NSKeyValueObserving.

Nevertheless, what I suggested does work. Let me know if you need me to send
you a working code example.

>I still wish I understood why the default hadn't changed after the
>save and synchronize

Let's not go there. The "synchronize" was unnecessary and in any case you
didn't show any code so it's impossible to say what the problem was. In
future, if you do want help, show code. m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: [[NSDate alloc] initWithString] crashes with valid string

2008-07-16 Thread Matt Neuburg
On Tue, 15 Jul 2008 11:36:46 -0700, Markus Spoettl
<[EMAIL PROTECTED]> said:
>Hi List,
>
>   I've a problem I am failing to track down (let alone understand)
>for a couple of weeks now. My application imports XML files that
>contain - amongst other things - dates. Once in a while, the string to
>date conversion causes a crash (EXC_BAD_ACCESS):
>
>#0 0x90b1da14 in ures_getIntVector
>#1 0x90b20eb0 in icu::Calendar::setWeekCountData
>#2 0x90b1f463 in icu::GregorianCalendar::GregorianCalendar
>#3 0x90b1ee16 in icu::Calendar::createInstance
>#4 0x90b1c73e in ucal_open
>#5 0x940a097b in __CFCalendarCreateUCalendar
>#6 0x940a0a22 in __CFCalendarSetupCal
>#7 0x940a15d7 in _CFCalendarComposeAbsoluteTimeV
>#8 0x95428cbc in -[NSCFCalendar dateFromComponents:]
>#9 0x9542879b in -[NSDate(NSDate) initWithString:]
>
>This specific crash happened with the string: "2008-05-09 19:47:47
>+", which seems perfectly valid input for NSDate -initWithString:.

This is not really relevant, but I just wanted to mention that I have found
string-to-date conversion extraordinarily touchy. In 2003 I filed a bug
pointing out that given a string @"Thu, 3 Jul 2003 09:45:01 -0600 " (notice
the space after the 0600), NSDate dateWithNaturalLanguageString would crash
with an "internal error". Maybe there are stray spaces or nulls or some
other invisibles affecting your situation here. m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Handling key equivalents in a controller class?

2008-07-16 Thread Matt Neuburg
On Wed, 16 Jul 2008 10:05:52 -0700, Jens Alfke <[EMAIL PROTECTED]> said:
>I've run into this problem a few times now: I have an
>NSWindowController subclass that manages a window. I want to handle
>certain hot-keys in this window, for example Esc to exit full-screen
>mode, or maybe use letter keys to switch tools as in Photoshop. Where
>do I put the handler for this?
>
>When this happened in the past I added a -performKeyEquivalent: method
>to a custom view in the window. However, this only makes sense
>architecturally if the action is related to that view; and if the view
>is a standard class (like NSTableView) then I have to subclass it just
>to add that one method. (AppKit doesn't send -performKeyEquivalent up
>the responder chain to the window's delegate, only to the views in the
>window.) This seems contrary to Cocoa's usual philosophy of delegation.
>
>Am I missing something?

Implement keyDown: in the NSWindowController? I'm not seeing a reason why
you need performKeyEquivalent to catch unmodified Esc and letter keys...
Actually I'm fond of sticking a singleton NSResponder into the chain after
the window and implementing keyDown: there. m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSButton setKeyEquivalent doesn't seem to work

2008-07-16 Thread Matt Neuburg
On Wed, 16 Jul 2008 17:12:31 -0400, Brian Hughes <[EMAIL PROTECTED]>
said:
>
>I want the default button to reflect where the user has decided to enter
information.  I have a sign up / log in page.  If the user is new and is signing
up I want the signUp button to be the default but if the user is already signed
up and elects to use the log in field I want the logIn button to be default.
>
>I have assigned the signIn Button to be the default in Interface Builder by
designating the key equivalent to be the return key.  When the user elects to
log in I want the default button to become the logIn Button.  Here is my code:
>
>
>- (void )controlTextDidBeginEditing: (NSNotification *) aNotification
>{
> if ([logInNameField isEqual: [aNotification object]])
> {
>  [logInButtonOutlet setKeyEquivalent: @"/r"];
>  [signUpButtonOutlet setKeyEquivalent: @""];
>
>  NSLog (@"The key equivalent for log in Field is: %@", [logInButtonOutlet
keyEquivalent]);
>  NSLog (@"The key equivalent for log in Field is: %@", [signUpButtonOutlet
keyEquivalent]);
> }
>
>}
>
>The log shows that the key equivalent for the logIn Button is now /r, the login
Button highlights blue and the key equivalent for signUpButton is "" but the
logIn Button's  action is not invoked if the return button is pressed.
>
>Any help would be appreciated.

One thing that instantly comes to mind is that a forward slash is not a
backward slash. m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Problem compiling first Cocoa app

2008-07-18 Thread Matt Neuburg
On Fri, 18 Jul 2008 07:34:56 -0700, "Paul Denlinger"
<[EMAIL PROTECTED]> said:
>I'm working on my first Cocoa lesson at
>http://www.cocoadevcentral.com/d/learn_cocoa/
>Everything works fine until I try to compile the app. I get error code 71.
>Can you tell me what's wrong? Here is the error message:
>
>*error: can't exec
>'/Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/c
opystrings'
>(No such file or directory)*

http://www.cocoabuilder.com/archive/message/xcode/2008/6/11/6

?

m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Handling key equivalents in a controller class?

2008-07-19 Thread Matt Neuburg
On Thu, 17 Jul 2008 09:31:53 -0700, Jens Alfke <[EMAIL PROTECTED]> said:
>
>On 16 Jul '08, at 2:53 PM, Matt Neuburg wrote:
>
>> Implement keyDown: in the NSWindowController?
>
>keyDown: only gets sent to the key view, whether or not it handles
>that keystroke. Since the method returns void, there's no way for
>AppKit to tell whether a responder handled the keystroke or not, so it
>can't pass it up the chain.

Try it and see. Let's say we want to catch Esc directed to the window as a
whole (to exit full screen mode, if I recall your example). So what I would
do is to insert an NSResponder instance behind the window in the chain and
implement keyDown:. When an event arrives (arrives! It got here by being
handed up thru all the views and the window, which therefore clearly didn't
handle it), we look to see if it's for us - i.e., is it Esc or not. If it
is, we tell the window to do what it's supposed to do, and the event is not
handed any further up the responder chain. If not, we pass the event to
super and the event is handed on up the responder chain in the usual way,
and proceeds to the window controller and so on. I've been using this
technique for many years and haven't had any trouble with it. It seems to me
that this is just what the responder chain is for. m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Handling key equivalents in a controller class?

2008-07-21 Thread Matt Neuburg
On Sat, 19 Jul 2008 12:34:45 -0700, Jens Alfke <[EMAIL PROTECTED]> said:
>
>On 19 Jul '08, at 8:52 AM, Matt Neuburg wrote:
>
>> Try it and see. Let's say we want to catch Esc directed to the
>> window as a
>> whole (to exit full screen mode, if I recall your example). So what
>> I would
>> do is to insert an NSResponder instance behind the window in the
>> chain and
>> implement keyDown:.
>
>I had already tried implementing keyDown: in my controller object,
>which is the window's delegate, to no avail. But that class is just a
>direct subclass of NSObject, not NSResponder or NSWindowController. I
>tried changing its superclass to NSResponder, but that didn't help.
>
>Looks like I need to read up on the conceptual docs about the
>responder chain, to figure out how to make my object the window's next
>responder. (I've never manipulated the chain directly before.)

Well, as Solon used to say, "You learn something new every day, even if you
don't want to!" A good place to start might be here:

http://developer.apple.com/documentation/Cocoa/Conceptual/EventOverview/Hand
lingKeyEvents/chapter_6_section_3.html

As for inserting your own objects into the responder chain, this is a
technique I've discussed here many times, most recently just last week:

http://www.cocoabuilder.com/archive/message/cocoa/2008/7/14/212862

I used to do quite a bit of NSWindow subclassing (and if you look on the
archives you'll find me arguing for it in those days), but these days I lean
much more towards inserting singleton NSResponders into the responder chain.
If I want to modify the keyboard behavior of a particular view in a window,
such as a table view, I insert the NSResponder behind it. If I want to
modify the keyboard behavior related to a window as a whole, I insert the
NSResponder behind the window. m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Spotlight and NSPredicate

2008-07-23 Thread Matt Neuburg
On Wed, 23 Jul 2008 18:14:56 +0100, Pedro Teixeira
<[EMAIL PROTECTED]> said:
>Is is just me, or its impossible to use Spotlight for its simplest
>action: search a keyword in all metadata (* = "something"cdw)
>
>I really cant find a way to do this using NSPredicate...

http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/Predicates/Article
s/pSpotlightComparison.html

m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: External Program Control from within Cocoa App

2008-11-03 Thread Matt Neuburg
On Sun, 02 Nov 2008 17:25:01 -0500, Ronald Ramdhan <[EMAIL PROTECTED]>
said:
>Hey Everyone,
> I am working on a project where I would like to control external
>programs from within my Cocoa Application. For example, the ability to
>control a program like PowerPoint from within my code.
>
> Is there anyway to do this programmatically without the use of Apple
>Script?

Certainly. You can do it with Objective-C (through the Scripting Bridge), or
Ruby, or Python, or raw Apple events... or...

What you *can't* do it without it Apple *events*. AppleScript is just a
language. But Apple events are the system-level interapplication
communication mechanism on Mac. Since this is the mechanism in existence
when PowerPoint was written, it is the mechanism to which PowerPoint
conforms. Apple events, however, are language-neutral; they don't care how
you created and sent them.

See Appendix B of my book (and my online article about replacing AppleScript
with Ruby) for more info about that. m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Cannot change menu state in NSSearchField menu for more than once

2008-11-03 Thread Matt Neuburg
On Mon, 03 Nov 2008 08:58:20 +0100, Alexander Reichstadt <[EMAIL PROTECTED]> 
said:
>I found something really odd just now. The searchmenu is actually
>connected to an IBAction method. The NSLog sits in there and simply
>prints out the sender, i.e. the menuItem that triggered it.
>
>If I change the menu item in the UI the NSLog printout shows that it's
>another part of memory that triggered it as if I trigger the
>searchaction through my code, so the objects are not identical. It's
>not that I instantiate more than one menu

Yes, it evidently *is* that you instantiate more than one menu. Or at least
it's that you change what menu mySearchMenu (or some other pointer along the
line) is pointing to. Now you have to figure out how.

>, so it's not clear to me
>where the other menu-twin with the same menuItems comes from. When I
>try to retrieve the menu through the NSSearchFields cell-menu, it's
>empty. This makes me wonder where the menu is actually stored and how
>many instances for whatever purposes are kept alive under the hood. I
>definitely only know of one NSMenu instance referenced through one
>IBOutlet which should be the one attached to the NSSearchField, but
>somehow I end up with two at runtime.

This kind of thing can be caused, for example, by having an outlet called
e.g. myOutlet and a method called setMyOutlet:. Is that your situation?

I must say, however, that your debugging approach here is excellent. In your
first message, where you say that the menu stopped working after one use, I
was going to suggest that the reason was that you were accidentally
generating another menu and that mySearchMenu was no longer pointing where
you think. But you discovered this very fact for yourself - well done. m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Modal Dialog Issue

2008-11-03 Thread Matt Neuburg
On Mon, 3 Nov 2008 09:22:25 -0500, "Carmen Cerino Jr." <[EMAIL PROTECTED]>
said:
>I have a button that when clicked will display a modal dialog. My
>modal dialog is custom, and lives in its own Xib file. My issue is
>that the first time I click the button to make the dialog appear it
>does not latch it self onto the window like it should. If I go to
>dismiss the dialog with my cancel button, the dialog does not
>disappear but focus returns to my main window. Now the strange thing
>is if I go to click that button again, the modal dialog works as it
>should.

Here's a wild guess. It sounds like maybe the whole nib-loading process is
not getting a chance to complete (the first time you show the dialog). So,
instead of going directly from loadNibName to beginSheet, as you do here,
try "stepping out" to the next event loop after loadNibNamed by calling
another method with peformSelector:...afterDelay. m.

>My code is as follows:
>
>- (IBAction)signIn:(id)sender{
>   if(!ibUserAuthenticationWindow) {
>  [NSBundle loadNibNamed: @"UserAuth" owner: self];
>   }
>
>   [NSApp beginSheet: ibUserAuthenticationWindow
>  modalForWindow: ibMainWindow
>   modalDelegate: self
>  didEndSelector:  @selector(didEndSheet:returnCode:contextInfo:)
> contextInfo: nil];
>}
>
>- (IBAction)authenticationCancel:(id)sender
>{
>
>   [NSApp endSheet:ibUserAuthenticationWindow];
>
>}
>
>- (void)didEndSheet:(NSWindow *)sheet returnCode:(int)returnCode
>contextInfo:(void *)contextInfo{
>   [sheet orderOut:self];
>
>}
>
>Cheers,
>Carmen
>
>
>

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CALayer contents memory leak

2008-11-04 Thread Matt Neuburg
On Sun, 02 Nov 2008 22:08:04 -0700, Adam Fedor <[EMAIL PROTECTED]> said:
>I have a simple program with a memory leak that is driving me crazy.
>It's basically a slide show application (no I can't use IKSlideShow),
>where I repeatedly set an image in a CALayer. When run, the app
>increases in memory size by 10MB or so every time a new image is
>displayed.

This is NOT evidence for a leak. Do not attempt to second-guess that Mac OS
X virtual memory management system. In fact, do not guess. The only way to
know whether you have a leak is to use the memory analysis tools
(MallocDebug, Shark, what have you). m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSTableView Informal Protocal

2008-11-04 Thread Matt Neuburg
On Mon, 03 Nov 2008 11:00:38 -0600, Ron Green <[EMAIL PROTECTED]> said:
>'m a newb and am struggling to find documentation.
>
>Example:
>
>NSTableView: setObjectValue:forTableColumn:row
>
>I have looked through all the documentation for NSTableView and cannot
>find this method.
>Does anyone know where it is?
>
>(I know how to use it, I'm just looking for the documentation.)

Part of the trouble is that you have the name wrong. Method names don't
begin with "NS"; this is a method, not a class. In Xcode, summon the
documentation window (used to be option-command-shift-question mark), make
sure it is set to do an API search, and type

tableview:set

You can stop typing; you are there. m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CALayer contents memory leak

2008-11-04 Thread Matt Neuburg
On Tue, 04 Nov 2008 08:58:24 -0700, Adam Fedor <[EMAIL PROTECTED]> said:
>
>On Nov 4, 2008, at 8:23 AM, Matt Neuburg wrote:
>
>> On Sun, 02 Nov 2008 22:08:04 -0700, Adam Fedor <[EMAIL PROTECTED]> said:
>>> I have a simple program with a memory leak that is driving me crazy.
>>> It's basically a slide show application (no I can't use IKSlideShow),
>>> where I repeatedly set an image in a CALayer. When run, the app
>>> increases in memory size by 10MB or so every time a new image is
>>> displayed.
>>
>> This is NOT evidence for a leak. Do not attempt to second-guess that
>> Mac OS
>> X virtual memory management system. In fact, do not guess. The only
>> way to
>> know whether you have a leak is to use the memory analysis tools
>> (MallocDebug, Shark, what have you). m.
>>
>
>I have used ObjectAlloc and MallocDebug.  In ObjectAlloc you can see
>the graph of memory usage go up like a stair-step ad infinitum.

"Memory usage" is not a leak. "ad infinitum" is not measurement. The above
statement by you is not an example of "using" these tools. You should be
able to say: at moment 1, I have these objects; at moment 2 (presumably
after setting an image), I have these objects, and this particular object
right here should have been released and isn't. You can even say, if you are
using the tools right, exactly where the object got allocated and who puts
retains on it. Until you can say that such-and-such an action of the
application is allocating an object and at such-and-such a later time it
should have been released but was not, you don't have a leak. You're just
flying by the seat of your pants.

I will give two examples of phenomena that sound like yours but are not
leaks:

(1) Repeatedly opening large files from disk. This causes the memory
management system to map to those areas of disk. I had this problem in an
application that read many (say 100) large (say 30 MB each) image files from
disk and drew their thumbnails into a window. It was a problem, but it
wasn't a leak, and fixing it had to with the fcntl settings, not Cocoa
memory management.

(2) Repeatedly doing just about anything, even where memory is managed
correctly in theory, but where the event loop never idles so autorelease
pools are never cleaned up. For example I had an app that read some data and
manipulated some strings. Each intermediate string in the manipulation was
autoreleased by Cocoa, but when there was a LOT of this data, memory usage
grew until the application broke down. This was because autorelease is no
good to you unless the pool is actually released, and the pool is not
released until idle time. Putting in my own autorelease pool in the loop and
releasing it myself solved the problem. Again, this was not a leak; memory
was being managed correctly. It's just that there were too many objects
accumulating at one time.

m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Enumerating outlets automatically?

2008-11-06 Thread Matt Neuburg
On Thu, 6 Nov 2008 16:13:52 +1100, Graham Cox <[EMAIL PROTECTED]> said:
>Is there a way to enumerate the outlets of an object automatically?
>
>In a certain type of controller object I'm finding I'm writing a lot
>of code like this:
>
>[myOutlet1 setEnabled:NO];
>[myOutlet2 setEnabled:NO];
>... etc for another several dozen outlets ...
>
>If I could get a list of outlets (maybe as a dictionary with the ivar
>name as key) I could probably find much easier ways to do stuff to
>each one. I suspect the answer is no but I thought I'd ask anyway...

I had a similar problem in an app I wrote way back in the dark days before
bindings - and a dictionary is exactly what I ended up using. I didn't
generate the dictionary automatically, because my requirements were quite
complicated; the window had several "states", and when there was a change in
state, a lot of interface items had to change their states in some way,
simultaneously. The dictionary was in fact generated from a textfile loaded
as the app started up (so that I could maintain it easily without
hard-coding all the rules into the app itself), and the key was a tag
identifier, which was matched up with the desired control within the window
using a recursive form of viewWithTag:. m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


automatic table scrolling when nsarraycontroller selection changes

2008-12-17 Thread Matt Neuburg
My app is very simple and involves an NSTableView of one column bound to an
array controller. The app runs both on Tiger and Leopard. On Tiger, when my
code changes the array controller selection (e.g. add: or
setSelectionIndex:), the table scrolls so that the selection shows. On
Leopard, it doesn't. Is there some new setting I can use to get the Tiger
behavior to happen on Leopard? Thx - m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: automatic table scrolling when nsarraycontroller selection changes

2008-12-17 Thread Matt Neuburg
On or about 12/17/08 11:40 AM, thus spake
"rajendran_pichaimur...@mcafee.com" :

> [tableviewoutlet scrollRowToVisible:yourselectedrow] should solve your
> problem

Obviously, but that is exactly what I don't want to have to do. It is quite
wrong to have to target the view in response to a change in the model; this
is precisely what the controller is supposed to deal with automatically (and
on Tiger, it does).

> -Original Message-
> From:
> cocoa-dev-bounces+rajendran_pichaimurthy=mcafee@lists.apple.com
> [mailto:cocoa-dev-bounces+rajendran_pichaimurthy=mcafee@lists.apple.
> com] On Behalf Of Matt Neuburg
> Sent: Thursday, December 18, 2008 1:00 AM
> To: cocoa-dev@lists.apple.com
> Subject: automatic table scrolling when nsarraycontroller selection
> changes
> 
> My app is very simple and involves an NSTableView of one column bound to
> an array controller. The app runs both on Tiger and Leopard. On Tiger,
> when my code changes the array controller selection (e.g. add: or
> setSelectionIndex:), the table scrolls so that the selection shows. On
> Leopard, it doesn't. Is there some new setting I can use to get the
> Tiger behavior to happen on Leopard? Thx - m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, http://tinyurl.com/2ouo3b
Take Control of Customizing Leopard, http://tinyurl.com/2t9629
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: automatic table scrolling when nsarraycontroller selection changes

2008-12-23 Thread Matt Neuburg
On or about 12/17/08 1:11 PM, thus spake "Matt Neuburg" :

>> My app is very simple and involves an NSTableView of one column bound to
>> an array controller. The app runs both on Tiger and Leopard. On Tiger,
>> when my code changes the array controller selection (e.g. add: or
>> setSelectionIndex:), the table scrolls so that the selection shows. On
>> Leopard, it doesn't. Is there some new setting I can use to get the
>> Tiger behavior to happen on Leopard? Thx - m.

Since Tiger behaves properly in this regard (table scrolls to selection when
nsarraycontroller's selection changes), and Leopard does not, and since no
one has suggested I'm mistaken about this, I'll file a bug. I find it a
little amazing, though, that no one is pounding the table about this
already, since it wrecks my app's behavior on Leopard and must surely have
the same effect for others. m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, http://tinyurl.com/2ouo3b
Take Control of Customizing Leopard, http://tinyurl.com/2t9629
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Cocoa Apple Script Problem

2008-12-25 Thread Matt Neuburg
On Fri, 19 Dec 2008 10:11:19 -0800, John Nairn  said:

>This does work as expected
>
> tell front document
>  make new family at end
>  tell last family
>   set properties to {husband:"@I5@"}
>  end tell
> end tell
>
>This creates the object but does NOT set the properties
>
> tell front document
>  make new family at end with properties {husband:"@I5@"}
> end tell
>

I'm pretty sure this is covered in my book and in the online tutorial:

http://www.tidbits.com/matt/scriptability/scriptabilityTutorial.html

In any case "make new pair at end with properties" does work in the tutorial
example, so one approach might be to look at what I'm doing and see how we
differ. One guess, I think you may need to implement both

  insertObject:inXXXArrayAtIndex:

and

  insertInXXXArray:

But without seeing all of your code it's hard to guess what other important
pieces of the puzzle you may be omitting. :) m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Making an object release itself?

2008-12-31 Thread Matt Neuburg
On Wed, 31 Dec 2008 14:28:44 +1100, Jacob Rhoden 
said:
>I'm thinking PostReader class could have a static function that
>initialises a new PostReader object, tells it to start the work, and
>then do a [self release] after it has called the callback function
>'postsRead';

There is certainly nothing wrong, on the face of it, with an object telling
itself to release. This is quite common for singleton and temporary objects
(just what you're dealing with). m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Initial Prefs Setting Of Checkbox?

2008-12-31 Thread Matt Neuburg
On Tue, 30 Dec 2008 23:25:03 -0500, "Chunk 1978"  said:
>i have a few checkboxes in my prefs window which are bound... however,
>i was under the impression that i could easily set the very first load
>state of these boxes in IB by checking "Selected" (Inspector >
>Attributes > Visual > Selected) before the userdefaults are written...

There are two misunderstandings here, and the most important of them is the
second one, "before the user defaults are written". There should be NO SUCH
TIME. It is up to you register the default defaults (that is, the "initial"
value for user defaults before the user has had any chance to express an
opinion) before the app even finishes loading for the first time. That is
exactly what "registerDefaults" is for. In some cases, finding a
sufficiently early entry point can be a challenge; I typically resort to
+initialize.

m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Initial Prefs Setting Of Checkbox?

2008-12-31 Thread Matt Neuburg
On Wed, 31 Dec 2008 14:59:13 -0500, "Chunk 1978"  said:
>ok i get that... however, what if a developer intends to leave all
>checkboxes in preferences unchecked as the initial defaults, and there
>are only checkboxes or radio buttons, no colors, no numbers, etc... is
>it considered bad practice to not register these defaults if they are
>bound?  or is it better to keep code to a minimum and not register the
>defaults... are there any problems that can arise from not having
>defaults registered if their initial settings of the checkboxes is
>desired?

Yes - the problems that you were experiencing that you described in your
original post. m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Enable Scripting Failing - Missing something? Based on SimpleScripingVerbs sample

2009-01-14 Thread Matt Neuburg
On Tue, 13 Jan 2009 13:17:11 -0800, "Adam Venturella"
 said:

>OSAScriptingDefinition
>MyScriptingDef.def

(1) Why do you call it .def when the example so clearly calls it .sdef?

(2) There are lots of tutorials (including mine online, plus my book) on
getting started with scriptability.

m.
-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Report writer for Cocoa?

2009-01-14 Thread Matt Neuburg
On Wed, 14 Jan 2009 15:01:02 -0500, "Jon C. Munson II" 
said:
>I've looked at (and read) the printing-relevant Apple dox.  I've read the
>relevant chapter in Hillegass' book too.  I can see how much work writing
>pretty reports is going to be.
>
>Unless...
>
>I missed a point concerning an NSView - it knows about PDF, etc.
>
>The dox don't really go into this much, so here's a follow-on question to
>the first:
>
>If I take the time to draw out a view in IB with all my fields, etc., will
>that print as-is?  This, then, would become the report writer, right?

I would suggest breaking the problem down in to the basic elements of a
page, classifying the "kinds of thing" you'd like to have appear on the
printed page. By default, a view draws itself by asking its subviews to draw
themselves. Thus you can have your own special NSView subclasses that know
how to draw themselves, and combine them within superviews, and now
everything becomes very tight and simple and object-oriented and easily
maintained. If you want to design certain aspects of a view in IB, of course
you can, and you can load a nib multiple times to get multiple copies of it.

m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSUserDefaultsController not updating defaults via binding

2009-01-22 Thread Matt Neuburg
On Fri, 16 Jan 2009 15:24:45 -0800, Luke Evans  said:
>I tried a set up where some UI (slider) bound to a property on a
>class, and separately this class' init programmatically set up a
>binding to NSUserDefaultsController sharedUserDefaultsController to
>initialise both the property and indirectly the slider control to
>which it was also bound.
>
>This worked great for initialisation.  The property and slider were
>indeed initialised to the value in the user defaults, and I could
>change this externally and see the initial properly/slider value
>change.  However, I was expecting that this code (being a binding)
>would also result in the user defaults being updated as the property
>value changed (as a result of moving the slider or writing to the
>property in another way).  Unfortunately, this doesn't happen.
>
>I've used NSUserDefaultsController many times in direct binding with
>UI controls (like everyone else), and it works perfectly
>bidirectionally with the simple binding.   I have also used
>programmatic binding to and observing of NSUserDefaultsController
>sharedUserDefaultsController many times to listen to properties
>changing in a one-way sense.  This is the first time I have tried this
>kind of configuration.
>
>There's an easy work around - just use NSUserDefaults to read the
>initial value, and to manually update the default when the property
>changes - but the attraction of a binding was hard to resist.  The
>docs also seem to keep hinting "use NSUserDefaults as the primary
>access - don't use NSUserDefaultsController for everything" (my
>paraphrase), but the reasons behind this recommendation aren't spelled
>out.
>
>Has anyone had similar experiences?  Is it unreasonable to expect this
>kind of binding configuration to work?

This is a very old source of confusion, so next time before posting a
question like this, check the archives, where the matter has been beaten to
death. Basically the short answer to your question is that there is no such
thing as a bidirectional binding; but some classes (i.e. NSControls) know
how to set up a binding in conjunction with KVO in such a way that changes
at either end are reflected back to the other end. Your programmatic binding
is between a class property and the user defaults, neither of which knows
how to do that, so you didn't get bidirectionality. A simple solution is to
add a second binding between the class property and the user defaults
running the other way. m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Knowing when a NSArrayController is ready

2009-01-24 Thread Matt Neuburg
On Sat, 24 Jan 2009 09:07:59 +, "jonat...@mugginsoft.com"
 said:
>
>On 24 Jan 2009, at 02:43, David LeBer wrote:
>
>> This may be a stupid question, but I've had reason to wonder a
>> number of times.
>>
>> If I have an NSArrayController in a nib, bound to a MOC, configured
>> with an Entity name and set to prepare content:
>>
>> Is there a way to be notified when it has finished loading and
>> arranging it's objects?
>>
>Hi David
>
>Adding an observer on the controller's arrangedObjects property should
>do the trick.
>
>[arrayController addObserver:self forKeyPath:@"arrangedObjects"
>options:0 context:(void *)&ControllerContentContext];
>
>In a persistent document based app, for example, the controller's MO
>content is not yet available in - (void)windowControllerDidLoadNib:
>(NSWindowController *)windowController.
>Adding the observer means you can set up any dependent code when the
>binding/core data machinery has finished doing its thing.

Is that really true? I'm not saying you're wrong; I'm really asking. When I
posed the same question a couple of years back, I was told that the solution
is, do *not* "set to prepare content"; instead, load the data yourself by
calling fetchWithRequest:

[arrayController fetchWithRequest:nil merge:NO error:&error];

When that call returns, the data is ready. I just now tried adding
addObserver: to the mix, just as an experiment, and logging reveals that I
get two corresponding calls to observeValueForKeyPath:, *before*
fetchWithRequest: has returned. The two calls are quite far apart (half a
second or so). Well, I sure wouldn't want to run my "dependent code" half a
second too early. So I'm not convinced that this approach is entirely safe,
at least not without some further modification... m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Long load time of managed object context

2009-01-24 Thread Matt Neuburg

> Date: Fri, 16 Jan 2009 13:03:24 +0100
> From: Matteo Manferdini 
> Subject: Long load time of managed object context
> 
> I'm testing performance in my application, to see how it behaves with
> a big load of data inside of it. My application is core data based and
> uses array controllers in entity mode to fetch data.
> 
> What I discovered is that my app fetched all the managed objects
> present in core data, so I set the fetch predicate of array
> controllers at startup. This reduced dramatically the number of
> objects fetched. The problem though is that my app still takes a lot
> of time to start when is full of data.
> 
> I ran the app within instruments, and the core data fetches instrument
> confirms that this is not the problem (my app fetches only 20-30
> objects when starts). But running it under Shark I can see that for
> 4-5 seconds after startup the only call on the stack is to the app
> managed object context. So I think it has something to do with
> interaction between managed object context and data stored, even if I
> don't fetch all the data. If I empty the app or leave little data
> inside of it, it starts very quickly.
> 
> Does somebody know why this happens? Am I missing something obvious?
> Why does it take so much to the managed object context to load if I
> only fetch few objects? I always read that core data scales well and
> the programming guide states that 10.000 objects are not much for core
> data, but in my app it makes a big difference, so I'm wondering where
> I am wrong.

You don't say what format you're using, but if you're using XML, the entire
XML file has to be loaded and parsed, even before you fetch any objects. m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, http://tinyurl.com/2ouo3b
Take Control of Customizing Leopard, http://tinyurl.com/2t9629
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Knowing when a NSArrayController is ready

2009-01-24 Thread Matt Neuburg
On or about 1/24/09 10:17 AM, thus spake "jonat...@mugginsoft.com"
:

> I am also having horrible performance problems.
> A data set of 1500 items with a total on disk size of 1.8MB is taking
> more than 30 secs to load.
> Maybe NSArrayController -fetchWithRequest will improve things.

I would ask you the same question I just asked someone else on the list: are
you using the XML persistent storage format? Because, if so, you must expect
some delay, since even before you fetch any objects the entire XML file must
be loaded into memory and parsed.

I use XML because I want human readability for my data, so startup speed is
a sacrifice I am prepared to make. My data consists of about 5000 items, but
they are very simple; dealing with complex objects would take considerably
longer, one assumes. In order to cave-man-instrument the startup procedure
via NSLog, I do NOT prepare content or even bind my array controller's
managed object content in the nib; instead, I do it all manually in
awakeFromNib. Here are some NSLog timings:

2009-01-24 10:37:09.157 [788] awakening from nib
2009-01-24 10:37:09.269 [788] binding to MOC
2009-01-24 10:37:09.359 [788] creating whole shebang
2009-01-24 10:37:09.360 [788] adding persistent store
2009-01-24 10:37:13.877 [788] calling fetch
2009-01-24 10:37:14.192 [788] done calling fetch

Notice the big delay between "adding persistent store" and "calling fetch";
that consists a single line of code (calling addPersistentStoreWithType:).
So the delay there is nothing but the XML file being loaded and parsed. m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, http://tinyurl.com/2ouo3b
Take Control of Customizing Leopard, http://tinyurl.com/2t9629
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Possible reasons why "no help is available"?

2009-08-25 Thread Matt Neuburg
On Fri, 21 Aug 2009 18:19:32 -0500, Brant Sears  said:
>Hi. I'm trying to get a Help Book to open for my application.

This problem is nearly always caused by DNFD (Did Not Follow Directions).
Apple has provided the directions. Follow them! Follow them very, very
exactly.

I've made a tutorial movie laying stress on the key points:

http://www.apeth.com/writersua/implementAppleHelp.mov

m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


change in launch services binding behavior?

2009-09-03 Thread Matt Neuburg
I wonder whether someone (preferably from Apple) could provide details on
how Snow Leopard has changed its algorithm for how a document is bound to an
application, esp. when double-clicking the doc in the Finder.

In the past, where many apps could claim a file type / extension, such as
plain text / .txt, an app could say, "Yes, but this particular file is still
mine" by attaching its creator code to the file. BBEdit does this, for
example, when you use it to create a new .txt file. So that file, although
it is .txt, has BBEdit's icon and opens with BBEdit when double-clicked.

In Snow Leopard that is no longer true. The user can of course specify (with
Get Info in the Finder) that this file opens with BBEdit, but the app itself
appears to be powerless to do the same thing.

The last word on the subject is in a fairly old document on Launch Services:

> Preferred Application for a Document

> For individual document files (whether specified by a file-system reference or
> a URL with scheme file), the criteria are as follows:
> 
> If the user has specified an explicit binding for the document (or for the
> entire document type to which it belongs), the preferred application is the
> one the user has specified.

> If the document has a filename extension (or if one has been specified as a
> parameter to LSGetApplicationForInfo), find all applications in the Launch
> Services database that claim to accept documents with that extension.

> If the document carries a four-character file type (or if one has been
> specified as a parameter), find all applications that claim to accept files of
> that type.

> If more than one application has been found as a result of steps 2­3, apply
> the following criteria in the order shown:

> If the document carries a four-character creator signature (or if one has been
> specified as a parameter), give preference to any application that claims to
> accept documents with that signature (typically the application to which the
> signature belongs).

[etc.]

That sounds like it means: If there's an extension it has priority, but if
there's a conflict for that extension (more than one app has been found that
claims .txt) then give priority to the app whose creator code is the doc's
creator code. And indeed, that is how LS behaved in Leopard.

But in Snow Leopard, it doesn't. Yet the documentation has not been changed;
indeed, there are no Snow Leopard release notes for Launch Services. So
what's going on exactly?

m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: change in launch services binding behavior?

2009-09-05 Thread Matt Neuburg
On Thu, 03 Sep 2009 18:57:07 -0400, Gregory Weston  said:
>Matt Neuburg wrote:
>
>> I wonder whether someone (preferably from Apple) could provide
>> details on
>> how Snow Leopard has changed its algorithm for how a document is
>> bound to an
>> application, esp. when double-clicking the doc in the Finder.
>
>I've done a little bit of experimenting on that a couple of days ago,
>after someone at Adobe asserted that 10.6 doesn't support creator
>codes

Yeah, that's just FUD. It supports creator codes, but not in the same *way*
that Leopard did. And since this is a major undocumented change, which has
broken the way apps like BBEdit and Nisus (and I guess some Adobe apps)
work, I'm hoping to get some official word on what's going on. m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Input Managers in Snow Leopard

2009-09-05 Thread Matt Neuburg
On Fri, 4 Sep 2009 11:54:17 +0700, "Gerriet M. Denkmann"
 said:
>I would like to modifiy apps (e.g.
>TextEdit) to put miniaturized windows NOT into the dock, but on the
>bottom of the screen (the way it was done in NeXTstep).

I would like you not to. m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: help book and appleicon meta tag

2009-09-06 Thread Matt Neuburg
On Sun, 6 Sep 2009 09:10:26 -0700 (PDT), "Rick C."  said:
>hello again,
>
>i have revised my help book and the problem i'm having is with the AppleIcon
meta tag and getting my icon to show in the help book.  i never had a problem
with the previous version of my help book and now all the paths are identical
i've made sure of it, yet no icon.  my guess is with some of the new html/css
i've put into my help that something is conflicting with the AppleIcon tag.  has
anyone experienced something like this before?  and is there another way to
setup the icon without using the new .help style books?  for the record my tag
is like this:
>
>
>the help displays fine it's just the icon.  thanks for the help,

What if you change the URL to "../mypic.png"?

m.

PS This is really the wrong list for this stuff, you know.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


adding a page curl transition

2009-09-13 Thread Matt Neuburg
My extremely simple Core Data app represents a bunch of "flashcards", shown
one at a time; in other words, I change the selected entity and presto, a
different card's contents are displayed in the various fields of my single
window.

I'm thinking it would be cute to add a page curl transition, so that when
the user goes from one flashcard to the next, the whole window peels off
from the upper right to reveal the next card.

My question is simply this: what's the best strategy for implementing this?
Unlike the Reducer tab view example, I don't have a view in advance
representing the future state of the window (i.e. what it will look like
after the transition). I'm not substituting one view for another, I'm
altering the content of a whole bunch of fields at once and I want the
*whole* window to peel back to reveal the new values.

I'm thinking this is probably such a common thing to want to do that someone
has already been down this road. Thx - m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: adding a page curl transition

2009-09-14 Thread Matt Neuburg
On Mon, 14 Sep 2009 13:57:32 +1000, Graham Cox 
said:
>
>On 14/09/2009, at 1:31 PM, Matt Neuburg wrote:
>
>> My question is simply this: what's the best strategy for
>> implementing this?
>> Unlike the Reducer tab view example, I don't have a view in advance
>> representing the future state of the window (i.e. what it will look
>> like
>> after the transition). I'm not substituting one view for another, I'm
>> altering the content of a whole bunch of fields at once and I want the
>> *whole* window to peel back to reveal the new values.
>>
>> I'm thinking this is probably such a common thing to want to do that
>> someone
>> has already been down this road. Thx - m.
>
>I've implemented this in a simple slideshow app that you can download
>the source for. I just use Core Image - no point trying to roll your
>own when the OS has a solution built right in - you need to have two
>images in memory, the current one and the next one to show

Ah, but the crux of my question is that I don't have "the next one to show".
I don't know what the window will look like when selecting a different core
data entity until I select it, and by then it's too late. That's why I'm
asking for a strategy...

For example, I can imagine something like this. Take a "screen shot" of the
window. Cover the whole window with a secondary window. Behind the secondary
window, move the primary window on to the next entity. Take a second "screen
shot" of the window. Now I *do* have a "before" and "after" pair of
pictures. Perform the page curl animation in the secondary window, and
remove it.

That seems very elaborate, so before I do that I'm checking to see whether
that strategy is on the right track. m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Help book content

2009-09-14 Thread Matt Neuburg
On Sat, 12 Sep 2009 14:31:14 +0100, Andy Bettis  said:
>Hi,
>
>I'm trying to add a help book to one of my apps and am falling at what
>seems like the last hurdle. I've added a folder with the help files to
>my Resources group and added Help Book directory name, Help Book
>identifier and Help file to my Info.plist file. When I run the app I
>can choose my application help from the Help menu but when the Help
>Viewer loads it says "Help Viewer cannot open this content". I've cut
>down my top-level help html file to virtually nothing but I still get
>the same message. It displays fine in Safari.
>
>I've not been able to work out what's happening from the Apple
>documentation (so far) - it refers to lots of plist entries that don't
>appear when I use the pop-up menu to choose them in the Xcode plist
>editor and that don't seem to be used in other applications'
>info.plist files. Am I missing something obvious?

This is almost always caused a failure to follow directions. You must do
everything *exactly* as described by the documentation. I've made a tutorial
screencast that emphasises the key tasks:

http://www.apeth.com/writersua/implementAppleHelp.mov

m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Help book content

2009-09-14 Thread Matt Neuburg
On Mon, 14 Sep 2009 20:39:30 +0100, Andy Bettis  said:
>Hi,
>
>Many thanks to all who replied, most especially Matt for your very
>helpful screencast.

Ye! :)

>It seems like changes to the help book don't percolate through to
>Xcode very well, especially in debug builds.

Yeah, this is a major issue. Most of us have a routine where we dive into
the Caches folder and remove a bunch of help-related stuff, between runs, so
that the help cache will be rebuilt on the next run.


>The only remaining problem is with links. I have a link between html
>pages on the same level:
>
>Presets
>
>This works in Safari but not through Help Viewer.

I'm surprised it *ever* works since that is not HTML. You need to say  (notice the quotes). Always run your HTML thru a
validator and if at all feasible use XHTML because it is even stricter and
clearer. m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: adding a page curl transition

2009-09-14 Thread Matt Neuburg
On Mon, 14 Sep 2009 09:32:11 -0700, Matt Neuburg  said:
>For example, I can imagine something like this. Take a "screen shot" of the
>window. Cover the whole window with a secondary window. Behind the secondary
>window, move the primary window on to the next entity. Take a second "screen
>shot" of the window. Now I *do* have a "before" and "after" pair of
>pictures. Perform the page curl animation in the secondary window, and
>remove it.
>
>That seems very elaborate, so before I do that I'm checking to see whether
>that strategy is on the right track. m.

Well, no one said it was a bad idea so that is what I ended up doing.
Actually, to be more precise, my current strategy, now pretty well fleshed
out, is as follows:

(1) At app launch I make an invisible child window with a layer, ignoring
mouse events, laid over the actual window. The user is unaware of its
existence. It's just a pane of glass; because it's a child window, it moves
with the main window.

(2) When the time comes to display another entity, I take a "screen shot" of
my main window and display that in the child window's layer, which is now
opaque, thus hiding the main window. The user doesn't see anything happen
because the image in the child window looks just like what was showing in
the main window.

(3) Now in the main window I display the other entity, but the user can't
see that; the child window and its layer are hiding it. Now I take a second
"screen shot" of my main window.

(4) Now I perform the animated transition in the layer, using the second
screen shot as the target image.

(5) Finally, after the animation is over, I turn the layer to transparent
glass once again. The user doesn't see anything happen because the contents
of the layer look just like the contents of the main window revealed behind
it.

The only problem with this approach so far is that the "screen shot" omits
the resize handle at the lower right of the window. I guess that's because
it isn't part of the window's content view. I'm using
cacheDisplayInRect:toBitmapImageRep: to take the "screen shot". Maybe
there's a better way? Apart from that, the illusion is extremely convincing.
m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Help book content

2009-09-14 Thread Matt Neuburg
On or about 9/14/09 5:55 PM, thus spake "Kyle Sluder"
:

>> Always run your HTML thru a
>> validator and if at all feasible use XHTML because it is even stricter and
>> clearer. m.
> 
> Don't do this.  XHTML is not a strict subset of HTML.

I didn't say it was. But it does work. :) All my help books are XHTML. m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: adding a page curl transition

2009-09-14 Thread Matt Neuburg
On or about 9/14/09 5:53 PM, thus spake "Graham Cox"
:

> I'm not sure your interface will really make much sense to an end-user
> (since it's uncommon and therefore unexpected behaviour)

Well, it wasn't uncommon back on System 6 and 7 using HyperCard. :) m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Filtering a table view using NSSearchField

2009-09-15 Thread Matt Neuburg
On Mon, 14 Sep 2009 17:36:57 -0600, PCWiz  said:
>Hi,
>
>I'm trying to filter a NSTableView using the contents of an
>NSSearchField. I have an Array Controller and table columns bound to
>key paths in the array controller. So for example I have the table
>column for name is bound to Array Controller.arrangedObjects.name.
>
>Everything up to this point is working fine, as the table view is
>populated with info correctly and all. What I want to do now is filter
>the contents of the table view (based on the name column) using text
>typed into an NSSearchField. So if the user types "test" into the
>search field, then anything row that doesn't contain "test" in its
>name gets removed.
>
>I know this is somehow possible using bindings and predicates, but im
>not sure exactly how to do it.

Download my app Thucydides. It's short and sweet and comes with example
source code which exemplifies exactly what you're describing. In fact, what
you're describing is just about all it does.

(And it's still working, unchanged, after all these years, even in Snow
Leopard...; the interface behavior has gotten a *little* creaky and
eventually I'll update it, but I'm in no rush.) m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Help book content

2009-09-15 Thread Matt Neuburg
On Mon, 14 Sep 2009 18:16:57 -0700, Kyle Sluder 
said:
>On Sep 14, 2009, at 6:14 PM, Matt Neuburg  wrote:
>
>> I didn't say it was. But it does work. :) All my help books are
>> XHTML. m.
>
>Well if you're going to write XHTML, that makes sense. But using an
>XHTML validator on HTML is worse than not validating at all, because
>it can give you incorrect results.

Obviously. But that isn't what I advised. I said:

> Always run your HTML thru a
> validator and if at all feasible use XHTML because it is even stricter and
> clearer.

I didn't say to validate HTML with an XHTML validator; I said to validate,
and also to write your pages in XHTML if you can. Naturally any decent
validator will use the doctype to validate appropriately; it will validate
HTML as HTML and XHTML as XHTML. (Indeed, using a validator will force you
to *have* a doctype in the first place.) m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


wait until the button releases

2009-09-15 Thread Matt Neuburg
In my code I sometimes want to wait until the button that triggers my code
has released itself (e.g. unhighlighted). My way of doing this is with
delayed performance, i.e. the button's action method calls
performSelector...afterDelay and then the real stuff happens. Just
wondering: Is there a better approach? I guess I'm looking for a command
that means "wait for the event loop to come round again". m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


settings to build for 10.5 on 10.6?

2009-09-16 Thread Matt Neuburg
What are the correct build settings to develop on 10.6 in such a way that my
app will also run on 10.5? (It runs fine on my 10.6 machine.)

I've already set the SDK and Base to 10.5, and my app does launch
successfully (if I set it to 32 bit) on my Leopard MacBook, and all of *my*
code runs okay (I'm not making any 10.6-only calls AFAIK), but as soon as my
app tries to perform an animation (CoreAnimation), it crashes (here's a
snippet from the crash log):

Code Type:   X86 (Native)
...
Thread 0 Crashed:
0   com.apple.CoreGraphics0x9295ccf0
sseCGSConvertTransposePermute + 368
1   com.apple.CoreGraphics0x928d9526 argb32_image + 886
2   libRIP.A.dylib0x96031372 ripl_Mark + 38
3   libRIP.A.dylib0x96033977 ripl_BltImage + 1307
4   libRIP.A.dylib0x9601d549 ripc_RenderImage + 273
5   libRIP.A.dylib0x9602de6a ripc_DrawImage + 5102
6   com.apple.CoreGraphics0x928cd17d CGContextDrawImage + 397
7   com.apple.QuartzCore  0x9425c85f create_image_by_rendering +
469
8   com.apple.QuartzCore  0x9425c358 CARenderImageNewWithCGImage
+ 928
9   com.apple.QuartzCore  0x942842e0 CARenderPrepareCGImage + 25
10  com.apple.QuartzCore  0x942842b5 CALayerPrepareCommit + 242
11  com.apple.QuartzCore  0x94258543 CAContextCommitTransaction
+ 187
12  com.apple.QuartzCore  0x94258239 CATransactionCommit + 229
...

I'm wondering whether I need to throw some additional switch to make my app
call CoreAnimation differently here...? Thanks. m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: settings to build for 10.5 on 10.6?

2009-09-16 Thread Matt Neuburg
I guess I wasn't clear. Deployment target is 10.5. Base SDK is 10.5. Runs
fine on 10.6 but crashes in Core Animation on 10.5. The question is what
*else* I need to change to make it run on 10.5.

To put it another way: if you are developing on 10.6 and your app
successfully does Core Animation on 10.5, I'd like to know what your
settings are that make this possible. m.

On Wed, 16 Sep 2009 14:14:41 -0400, Ross Carter  said:
>
>On Sep 16, 2009, at 1:03 PM, Matt Neuburg wrote:
>
>> What are the correct build settings to develop on 10.6 in such a way
>> that my
>> app will also run on 10.5? (It runs fine on my 10.6 machine.)
>>
>> I've already set the SDK and Base to 10.5, and my app does launch
>> successfully (if I set it to 32 bit) on my Leopard MacBook, and all
>> of *my*
>> code runs okay (I'm not making any 10.6-only calls AFAIK), but as
>> soon as my
>> app tries to perform an animation (CoreAnimation), it crashes
>> (here's a
>> snippet from the crash log):
>>
>> Code Type:   X86 (Native)
>> ...
>> Thread 0 Crashed:
>> 0   com.apple.CoreGraphics0x9295ccf0
>> sseCGSConvertTransposePermute + 368
>> 1   com.apple.CoreGraphics0x928d9526 argb32_image + 886
>> 2   libRIP.A.dylib0x96031372 ripl_Mark + 38
>> 3   libRIP.A.dylib0x96033977 ripl_BltImage + 1307
>> 4   libRIP.A.dylib0x9601d549 ripc_RenderImage +
>> 273
>> 5   libRIP.A.dylib0x9602de6a ripc_DrawImage + 5102
>> 6   com.apple.CoreGraphics0x928cd17d CGContextDrawImage
>> + 397
>> 7   com.apple.QuartzCore  0x9425c85f
>> create_image_by_rendering +
>> 469
>> 8   com.apple.QuartzCore  0x9425c358
>> CARenderImageNewWithCGImage
>> + 928
>> 9   com.apple.QuartzCore  0x942842e0
>> CARenderPrepareCGImage + 25
>> 10  com.apple.QuartzCore  0x942842b5
>> CALayerPrepareCommit + 242
>> 11  com.apple.QuartzCore  0x94258543
>> CAContextCommitTransaction
>> + 187
>> 12  com.apple.QuartzCore  0x94258239 CATransactionCommit
>> + 229
>> ...
>>
>> I'm wondering whether I need to throw some additional switch to make
>> my app
>> call CoreAnimation differently here...? Thanks. m.
>>
>
>Matt, I think you want to look at the Mac OS X Deployment Target
>setting. It should be 10.5. Base SDK can be 10.6.
>
>
>

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: settings to build for 10.5 on 10.6?

2009-09-17 Thread Matt Neuburg
On or about 9/17/09 9:55 AM, thus spake "David Duncan"
:

> On Sep 16, 2009, at 7:13 PM, Matt Neuburg wrote:
> 
>> I guess I wasn't clear. Deployment target is 10.5. Base SDK is 10.5.
>> Runs
>> fine on 10.6 but crashes in Core Animation on 10.5. The question is
>> what
>> *else* I need to change to make it run on 10.5.
> 
> 
> There are no other required build settings. More than likely you are
> seeing a behavioral difference between 10.6 and 10.5 and we would need
> to see the code that leads up to this crash to have a chance of
> understanding what is going wrong.

I'm happy to try to reduce this to a simpler case, but before I do that - I
thought that setting the deployment target and base sdk to 10.5 meant that
there was *no* such difference? In other words, don't these settings mean,
"give me 10.5 behaviors, even though my development machine happens to be
10.6"?

If that is not so, then clearly in order to develop *for* 10.5 I should be
developing *on* 10.5, not on 10.6 (which would be a pity because I'd lose
all the tangy Xcode 3.2 goodness...). m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: CAAnimation finished ?

2009-09-17 Thread Matt Neuburg
On Wed, 16 Sep 2009 19:50:39 -0500, Kevin Cathey  said:
>For more, see previous posts on the mailing list.

Not so easy; searching Apple's archives doesn't retrieve anything after
2005, which sort of makes the search feature unusable. (And Cocoabuilder has
issues of its own.) m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


bitmap caching issue (was: settings to build for 10.5 on 10.6?)

2009-09-20 Thread Matt Neuburg
Okey-dokey, I'm back with more information. I have finally tracked down the
source of my Core Animation crash on 10.5 (the problem, you may recall, is
that it's crashing on 10.5 but working just fine on 10.6). And it has
nothing to do with my build settings after all.

Here's the story. My animation is a transition based around setting a
layer's contents. The crash, it turns out, has to do with how I'm acquiring
the CGImages used to set the layer's contents. I'm acquiring them from a
"screen shot" of a window (see my thread "adding a page curl transition").
Like this (v is a window's content view, fglayer is the CALayer that does
the animation):

NSBitmapImageRep* b = [v bitmapImageRepForCachingDisplayInRect: [v
visibleRect]];
[v cacheDisplayInRect:[v visibleRect] toBitmapImageRep:b];
fglayer.contents = (id)[b CGImage];

If I set the contents of the layer that way on 10.6, everything is fine. If
I do it on 10.5, I crash during the resulting animation. I am guessing that
the reason has something to do with image / bitmap caching. On 10.5, the
CGImage isn't really there, I'm guessing; it's as if the bitmap and the
CGImage are places to draw to but they don't really have any separate
existence. On 10.6, where the nature of window drawing has changed somehow,
they do exist, and everything works.

I can solve the problem - prevent the crash - on 10.5 by copying the bitmap
off to a TIFFRepresentation and turning *that* into a CGImage. So from that
point of view the problem is solved! But is there a better way? Is there
some simpler (or "correct") way to make my CGImage real - to say "Draw here,
draw now?" (I tried things like retaining or copying the CGImage and that
didn't work.) m.

>>On Sep 16, 2009, at 1:03 PM, Matt Neuburg wrote:
>>
>>> I've already set the SDK and Base to 10.5, and my app does launch
>>> successfully (if I set it to 32 bit) on my Leopard MacBook, and all
>>> of *my*
>>> code runs okay (I'm not making any 10.6-only calls AFAIK), but as
>>> soon as my
>>> app tries to perform an animation (CoreAnimation), it crashes
>>> (here's a
>>> snippet from the crash log):
>>>
>>> Code Type:   X86 (Native)
>>> ...
>>> Thread 0 Crashed:
>>> 0   com.apple.CoreGraphics0x9295ccf0
>>> sseCGSConvertTransposePermute + 368
>>> 1   com.apple.CoreGraphics0x928d9526 argb32_image + 886
>>> 2   libRIP.A.dylib0x96031372 ripl_Mark + 38
>>> 3   libRIP.A.dylib0x96033977 ripl_BltImage + 1307
>>> 4   libRIP.A.dylib0x9601d549 ripc_RenderImage +
>>> 273
>>> 5   libRIP.A.dylib0x9602de6a ripc_DrawImage + 5102
>>> 6   com.apple.CoreGraphics0x928cd17d CGContextDrawImage
>>> + 397
>>> 7   com.apple.QuartzCore  0x9425c85f
>>> create_image_by_rendering +
>>> 469
>>> 8   com.apple.QuartzCore  0x9425c358
>>> CARenderImageNewWithCGImage
>>> + 928
>>> 9   com.apple.QuartzCore  0x942842e0
>>> CARenderPrepareCGImage + 25
>>> 10  com.apple.QuartzCore  0x942842b5
>>> CALayerPrepareCommit + 242
>>> 11  com.apple.QuartzCore  0x94258543
>>> CAContextCommitTransaction
>>> + 187
>>> 12  com.apple.QuartzCore  0x94258239 CATransactionCommit
>>> + 229
>>> ...

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: bitmap caching issue (was: settings to build for 10.5 on 10.6?)

2009-09-20 Thread Matt Neuburg
On or about 9/20/09 1:16 PM, thus spake "Ken Ferry" :

> There was an ownership problem.  The NSBitmapImageRep owned a raw buffer of
> data and the CGImage.  The CGImage didn't retain the NSBitmapImageRep since
> that would cause a retain cycle.  

So all I had to do was retain the NSBitmapImageRep! I never thought of
that!!! Argh! [Falls on own sword in despair, is carried off the stage.] m.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: IB does not show Outlet/Action section in inspector

2009-09-22 Thread Matt Neuburg
On Tue, 22 Sep 2009 08:57:14 +0200, Michael S?ssner
 said:
>When I select an object in IB, the inspector does not display the
>outlet/action section.
>
>Is this a bug?
>I have installed Xcode on another computer and experienced the same
>behaviour.
>
>I am using Xcode3.2 and snow leopard.

(1) This is an Xcode question, not a Cocoa question, and belongs on the
Xcode list.

(2) Select *how*? Single-clicking an object in IB does not change what the
inspector shows; it is up to you to navigate the inspector. Double-clicking
an object in IB does not bring up a dialog where you can create outlets and
actions, as it did in earlier versions; instead, you create outlets and
actions in Xcode (in your header, in code) and IB automatically sees them.

m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Using radio buttons to set an image in an image view

2009-09-22 Thread Matt Neuburg
On Tue, 22 Sep 2009 11:40:10 +0100, Martin Hawkins
 said:
>I can set the initial value of the image by using
>
>actionImagePath = [NSMutableString stringWithString: @"/Users/.../one.jpg"];
>// the full path is hard coded at the moment - worry about that later
>
>as the value path for the  image view is bound to actionImagePath.
>
>What I cannot do is change the image. When I click on the second radio
>button, I use
>
>[actionImagePath setString:@"/Users/.../two.jpg"];

That change is happening "behind the back" of KVO (key-value observing), so
the binding does not know about it. m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: building and running on Snow Leopard

2009-09-23 Thread Matt Neuburg
On Wed, 23 Sep 2009 03:39:23 -0700 (PDT), Chris Idou 
said:
>From: Ken Thomases 
>
>>Don't test whether you're running on Leopard.
>
>Well I'm thinking of a particular bug on Leopard with MDItemCreate where you
have to choose between your program crashing and leaking memory.

Yes, Ken's advice doesn't make sense to me here. Certainly there will be
situations where you want to use Gestalt to test what system you're running
on.

I've just started the process of updating my various little Tiger-and-before
apps for Snow Leopard. Dealing with the problem of whether to run on Leopard
too has been tricky. I was hoping that setting my deployment target to 10.5
(and base to 10.6) would mean that on Snow Leopard I would magically crash
if the app was destined to crash on Leopard, but no such luck. :) The only
way is to copy the built app over to a Leopard machine, run it there, see
what happens, and then try to figure out what the heck it means. You can
spend hours puzzling over a single line of code (at least, I can). REALbasic
has "remote debugging", e.g. it lets you build and debug on a Mac while the
app (with all its breakpoints etc.) is running on a Windows machine, so you
can test your cross-platform compatibility; it would be really cool if Xcode
had something like that.

Plus of course in addition to systems there are architectures to take
account of. At a point where everything was fine on Snow Leopard, at the
same time, on Leopard I was crashing on startup in 64-bit, running fine in
32-bit, and running very weirdly in Rosetta. It took a while to get that
sorted out.

In the end I used a combination of Gestalt (what system are we running on?)
and #if __ppc__ (what architecture are we building for?) to tweak the app's
behavior as needed.

Of course you *could* just say "This app is Snow Leopard / Intel / 64-bit
only," and save yourself a lot of work. :)

m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: app delegate +initialize

2009-09-23 Thread Matt Neuburg
On Wed, 23 Sep 2009 08:26:58 -0700, Jens Alfke  said:
>This is why it's best to do your initialization in an -awakeFromNib
>method

Whoa, whoa. Let's be fair. There is some common initialization (such as
registering defaults, esp. when bindings are also involved) that *must* be
done in +initialize, as awakeFromNib is not early enough. And Apple's own
code examples advise and demonstrate this. m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Animating "contents" property of CALayer via the delegate

2009-09-28 Thread Matt Neuburg
On Mon, 28 Sep 2009 14:16:36 +0300, Oleg Krupnov 
said:
>I'd like to use Core Animation to create an arbitrary animation, that
>is, I have a number of custom-drawn frames that I want to render in a
>sequence, with a good frame rate, using the Core Animation timing
>engine. How do I do this?
>
>I am looking on CAKeyframeAnimation, which could do the job using the
>code like this:
>
>CAKeyframeAnimation *anim;
>  NSMutableArray *images;
>  CGImageRef im;
>  int i;
>
>  images = [NSMutableArray array];
>  for (i = 0; i < N; i++) {
> im = create_image (i);
> [images addObject:(id)im];
> CGImageRelease (im);
>  }
>
>  anim = [CAKeyframeAnimation animation];
>  [anim setKeyPath:@"contents"];
>  [anim setValues:images];
>  [anim setCalculationMode:@"discrete"];
>  [anim setRepeatCount:HUGE_VAL];
>  [anim setDuration:1.0];
>
>  [layer addAnimation:anim];
>
>However, I don't like to create all keyframe images at once, but
>instead draw them in process of animation, when the particular frame
>becomes the current frame, via the -[CALayer drawLayer:inContext:]
>delegate method. How do I do this? The delegate method seems to get
>called only once. Thanks!

You might find some architectural inspiration in Matt Gallagher's
"Asteroids" Core Animation example:

http://cocoawithlove.com/search/label/CoreAnimation

m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTextField, drawing the text offset to the right in the field

2009-09-28 Thread Matt Neuburg
On Mon, 28 Sep 2009 19:37:00 -0600, jon  said:
>i've got a textfield defined...
>but i don't want to draw the text that is in the field right up
>against the left boarder of the bounding box of this defined field in
>IB,
>
>I want to start the text like 20 pixels to the right of the left
>boarder  and still have the nicely defined frame of the field in it's
>original place...

What I do is have the textfield replace its cell by a custom cell that
implements drawInteriorWithFrame, such as to inset its frame rect as it
calls super. m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTextField, drawing the text offset to the right in the field

2009-09-29 Thread Matt Neuburg
On or about 9/29/09 4:43 PM, thus spake "jon" :

> is properly using my custom textfield,  but the custom textfield doesn't
> appear to be using the custom cell

Then you have to *make* the custom textfield use the custom cell. :) Use
whips and chains if necessary. Actually, I think what I said before may
cover this sufficiently:

> On Sep 28, 2009, at 9:30 PM, Matt Neuburg wrote:
>> What I do is have the textfield replace its cell by a custom cell that
>> implements drawInteriorWithFrame, such as to inset its frame rect as it
>> calls super. m.

As the first part states, an instance of your cell class must *be* this text
field instance's cell. You have to make that happen... m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Fast transition between two graphics

2009-09-29 Thread Matt Neuburg
On Wed, 30 Sep 2009 10:24:47 +1000, Rob Keniger  said:
>
>On 30/09/2009, at 4:16 AM, Chilton Webb wrote:
>
>> So now I'm experimenting with using an overlay window with layer
>> backed views, loading the images into the views, showing the window,
>> and drawing the animation by then translating the two views at the
>> same time. Is this the fastest way to do this?
>
>
>You could do it this way, although normally for something like this
>I'd use Core Image. Make two CIImages and use an animated transition
>CIFilter.

Right, that indeed is precisely the solution I ended up using for JACTVocab
2.0. My implementation is very similar to what the OP described: I'm
covering my window with a "glass" child window where I can use layers, and
calling setContent on a layer with an animated transition. (The app gives
the user a choice of transitions, and one of them is a push transition.) I
discussed my thinking in an earlier thread here as I was developing the
animation.

At the time, Uli Kusterer suggested it might have been better to swap views
and animate *that*. And I might still rewrite it that way. m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTextField, drawing the text offset to the right in the field

2009-09-30 Thread Matt Neuburg
Although, to be clear, you *can* do this is in code, just not the way you
were doing it. You have to make sure you're talking to this instance at the
right moment, i.e. before the window appear but after the instance (the text
field) has been assembled by the nib. That moment, of course, is
awakeFromNib.

So, in awakeFromNib, instantiate the cell (you know, alloc-init etc.) and
set the textfield's cell - not its cell class, its *cell* - to that cell
instance:

[theTextField setCell: theCell];

If you do this in the text field's own awakeFromNib, then *all* text field's
of this class will adopt the custom cell.

[self setCell: theCell];

Or you can do it from elsewhere to specify that just *particular* text
fields should adopt the custom cell.

m.

On Tue, 29 Sep 2009 20:06:08 -0600, jon  said:
>ahh,  that was it,   thanks a lot,   that made perfect sense once i
>looked inside IB
>I was also surprised that IB knew about my custom cell class...
>
>I was thinking code code code...   and i just needed that shove in the
>correct direction...
>you made my day,  after a very long day...

>On Sep 29, 2009, at 7:58 PM, Kyle Sluder wrote:
>
>> +setCellClass: just tells the view "Hey next time you initialize
>> yourself, make a cell of this class."  Since your ImageTextField
>> instance was created inside of IB, this is never going to happen.
>> Instead you need to change the class of the cell from within IB, under
>> the Identity inspector.  It might be helpful to switch to the
>> hierarchical view so you can get easy access to the text field's cell.


-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: properties attributes misunderstanding

2009-09-30 Thread Matt Neuburg
On Wed, 30 Sep 2009 15:02:45 +0200, Colin Howarth  said:

>@property (copy) NSBezierPath *path;
>an instance of which is accessed in another class:
> temporaryPathPointerWhichIsSupposedToBeDifferent = [ray.path];

>Why isn't it doing what I think it should do?

Take a look at the docs:

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Object
iveC/Articles/ocProperties.html

Search on "copy". It's all about the setter, not the getter.

m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: odd behavior with NSError?

2009-10-02 Thread Matt Neuburg
On Fri, 02 Oct 2009 07:05:37 -0400, Gregory Weston  said:
>Stephen J. Butler wrote:
>
>> On Thu, Oct 1, 2009 at 10:31 PM, Colin Howarth 
>> wrote:
>>>NSStringEncoding *enc;
>>>NSError *error;
>>>
>>>NSString *file = [NSString
>>> stringWithContentsOfFile:@"/Users/colin/developer/Trace/glass.csv"
>>> usedEncoding:enc error:&error];
>While we're at it, the values of enc and error are (effectively)
>nondeterministic before the message send. The documentation for the
>method you're invoking doesn't specify what it'll put into the
>encoding argument on failure or into the error argument on success,
>which means you really shouldn't be blindly using either of them after
>the call. It would be a good idea to get into the habit of
>initializing your local variables at the point of declaration.

And IIRC the Build and Analyze mechanism (clang?) will warn of this. Try it,
you'll like it! m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: app delegate +initialize

2009-10-07 Thread Matt Neuburg
On Tue, 6 Oct 2009 23:30:02 -0700, John Baldwin 
said:
>I put an NSLog statement at the beginning and end of the +initialize
>method to track when it gets called on the test machine.

This might not help, but I would suggest trying some other method of
confirming that +initialize is being called. The reason is that NSLog
messages are often significantly delayed getting into the Console, so merely
looking at the Console to see whether messages are showing up is not
conclusive. Even a simple NSBeep() would be more reliable. Naturally I don't
believe that +initialize is unreliably called, so I tend to suspect your
observation mechanism (Heisenberg uncertainty principle and all that...!) m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Any way to see all AppleEvents being sent in system?

2009-10-18 Thread Matt Neuburg
On Fri, 16 Oct 2009 18:45:54 -0700, Rick Mann  said:
>It often starts with one, then spreads to others. There is speculation
>online that that 65,535th event results in a long hang/timeout. I want
>to get an idea of how many events are really being sent during normal
>use (that is, not during heavily scripted use, etc).
>
>http://db.tidbits.com/article/10643

It isn't speculation. :)

If you think your app is hitting this bug, you don't need to *count* Apple
events; you need to know the return IDs of the Apple events that you are
sending. That's easy to find out. m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Using core data binary and string attributes with NSTextView

2009-10-18 Thread Matt Neuburg
On Sat, 17 Oct 2009 16:14:29 -0700, Robert  said:
>Now, after a lot of googling, I'm working on a solution that involves
>having a new transient attribute in my model of type string (let's
>call it storyText) that will mirror the text held in the binary data
>story attribute.   Instead of my search field using the "story"
>attribute, it will use the "storyText" attribute.
>To do this, I created .m and .h files for my model, and I'm
>implementing the accessor and setter for the storyText attribute.   In
>the accessor method, I get, using valueForKey, the story object.  The
>question now is, what do I do with it?  It appears that this object is
>an NSData object.  Am I correct about this?  What do I do with it to
>get it into an NSAttributed string on which I can extract the string?

Look at the binding for your TextView. It's getting its attributed string
from the managed object by passing the NSData through the
NSUnarchiveFromData transformer, right? So that's what *you* want to do -
unarchive the NSData to get an NSAttributedString.

As an aside, I would suggest you consider making the plain text version
*not* transient. In my Diary app, for example, the text that the user sees
and types in the NSTextView can have styles, but the text that the user
searches is a plain-text string. So when it's time to search, we don't need
to *create* the plain-text string - it's already there.

m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Any way to see all AppleEvents being sent in system?

2009-10-18 Thread Matt Neuburg
On or about 10/18/09 11:10 AM, thus spake "Rick Mann"
:

> I repeat. I'm not interested in any specific app. I'm just seeing my
> machine lock up periodically.

Then what's this doing on the Cocoa-Dev list? m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Showing activity indicator during data download

2009-10-29 Thread Matt Neuburg
On Thu, 29 Oct 2009 16:00:42 +, Alastair Houghton
 said:
>To be honest, it's going to be easiest just to use the asynchronous
>NSURLConnection approach.  It really isn't that hard

I'd have to agree with this. I just tried NSURLConnection for the first time
and it worked perfectly right out of the box. What was I so scared of? Apple
actually hands you all the code on a silver platter: you just copy it out of
the docs and into your code, tweak slightly, and presto, you are downloading
asynchronously. m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


nonsense from cellFrameAtRow:column: on Leopard

2009-10-30 Thread Matt Neuburg
I'm building on Snow Leopard but I want to run on Leopard too. I'm calling
NSMatrix's cellFrameAtRow:column: from an NSCell, like this:

NSInteger row, col;
[(CardMatrix*)[self controlView] getRow:&row column:&col ofCell:self];
NSRect myFrame = [
  (CardMatrix*)[self controlView] cellFrameAtRow:row column:col];

I can see from logging that this gives the right answers on my SnowLeopard
machine. For example, the NSRect of cell (0,0) is reported as

{{0, 0}, {130.5, 167.25}}

But on the Leopard machine it's reported as

{{608, 0}, {20, 0}}

I believe things really are going wrong (i.e. it isn't just the way I'm
logging) because myFrame causes Bad Things to happen later on in the code on
the Leopard machine. On Snow Leopard everything's fine.

I have a vague feeling that all this is due to something about 64-bit, and
maybe NSRect vs. CGRect, but what? Do I need to do some kind of tricky
conditional compilation and cast somehow? Do I need to tweak my build
settings? (I tried building 32-bit only but it made things worse.) Thx.

m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: nonsense from cellFrameAtRow:column: on Leopard

2009-10-31 Thread Matt Neuburg
Solved my own problem, which had nothng to do with what I thought it had to
do with. The source of the difficulty is actually this: On Snow Leopard,
[self controlView] works - it points from the NSCell to the NSMatrix that
contains it. On Leopard, it doesn't work.

I don't know why it doesn't work on Leopard, but I don't really care; I have
another way to get a reference to the NSMatrix, and that's all I need, so
now my code works fine on both Leopard and Snow Leopard.

Sorry for the misstatement of the problem. m.

On Fri, 30 Oct 2009 22:06:09 -0700, Matt Neuburg  said:
>I'm building on Snow Leopard but I want to run on Leopard too. I'm calling
>NSMatrix's cellFrameAtRow:column: from an NSCell, like this:
>
>NSInteger row, col;
>[(CardMatrix*)[self controlView] getRow:&row column:&col ofCell:self];
>NSRect myFrame = [
>  (CardMatrix*)[self controlView] cellFrameAtRow:row column:col];
>
>I can see from logging that this gives the right answers on my SnowLeopard
>machine. For example, the NSRect of cell (0,0) is reported as
>
>{{0, 0}, {130.5, 167.25}}
>
>But on the Leopard machine it's reported as
>
>{{608, 0}, {20, 0}}
>
>I believe things really are going wrong (i.e. it isn't just the way I'm
>logging) because myFrame causes Bad Things to happen later on in the code on
>the Leopard machine. On Snow Leopard everything's fine.
>
>I have a vague feeling that all this is due to something about 64-bit, and
>maybe NSRect vs. CGRect, but what? Do I need to do some kind of tricky
>conditional compilation and cast somehow? Do I need to tweak my build
>settings? (I tried building 32-bit only but it made things worse.) Thx.


-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: nonsense from cellFrameAtRow:column: on Leopard

2009-10-31 Thread matt neuburg
On Sat, October 31, 2009 12:49 pm, Jim Correia wrote:
> On Oct 31, 2009, at 2:34 PM, Matt Neuburg wrote:
>
>> Solved my own problem, which had nothng to do with what I thought it
>> had to
>> do with. The source of the difficulty is actually this: On Snow
>> Leopard,
>> [self controlView] works - it points from the NSCell to the NSMatrix
>> that
>> contains it. On Leopard, it doesn't work.
>
> See the section titled "NSCell controlView property changes” in the
> Snow Leopard AppKit release notes.

Spot on, thanks! m.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Create an NSCharacterSet constant

2009-11-01 Thread Matt Neuburg
On Sun, 1 Nov 2009 21:29:25 -0800, Kyle Sluder  said:
>I'm partial to the following construct:
>
>+ (Foo *)sharedFoo {
>  static Foo *sharedFoo;
>  dispatch_once_t once;
>  dispatch_once(&once, ^{ sharedFoo = [[foo alloc] init]; }
>  return sharedfoo;
>}

Why (I'm really asking, not arguing; I don't know anything about GCD) is
this better than the traditional:

+ (Foo*) sharedFoo {
   static Foo* sharedFoo = nil;
   if (nil == sharedFoo) sharedFoo = [[Foo alloc] init];
   return sharedFoo;
}

m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


CAAnimation retains its delegate

2009-11-02 Thread Matt Neuburg
Apropos of nothing at all, here's a little tip from the Department of
Lessons Learned: A CAAnimation retains its delegate, which is a severe
exception to the general rules and expectations about memory management. Of
course one can see why this might be (animations take time, so let's make
sure our delegate still exists when we need it later), and it is called out
loudly in the docs. But you might set the delegate without reading that part
of the docs.

I encountered this when I accidentally created a retain cycle. Fortunately I
was able to discover and track down the retain cycle quite easily, thanks to
the wonderful Instruments app. m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSMatrix -renewRows:columns: doesn't change cell count

2009-11-02 Thread Matt Neuburg
If I say:

[myMatrix renewRows:5 columns:5];

and then later:

[myMatrix renewRows:3 columns:3];
int i = [[myMatrix cells] count]; // i is 25

Is this a bug? I know that renewRows:columns: doesn't release cells (the
docs tell me so), but I do expect that the "cells" method will report the
cells that are part of the actual matrix (i.e. rows * columns), not the
whole bag of extra cells that the matrix is keeping on hand just in case. m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


priming the NSBeep pump?

2009-11-03 Thread Matt Neuburg
My app sometimes needs to beep to signal the user that something is a no-no.
The very *first* NSBeep() call issued after startup sometimes takes quite a
long time to make sound emerge from the computer - long enough that the user
feels that something has gone wrong (because nothing is happening, neither
the thing that was requested nor the beep).

Is there a way to "prime the pump" to eliminate this NSBeep() delay?

m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSMatrix -renewRows:columns: doesn't change cell count

2009-11-03 Thread Matt Neuburg
On Mon, 02 Nov 2009 19:28:28 -0800, Matt Neuburg  said:
>If I say:
>
>[myMatrix renewRows:5 columns:5];
>
>and then later:
>
>[myMatrix renewRows:3 columns:3];
>int i = [[myMatrix cells] count]; // i is 25
>
>Is this a bug?

Well, I have submitted it as one to Apple. We shall see what we shall see.

Personally I think that [myMatrix cells] should always provide an array of
references to the cells actually in use in the matrix, not to a bunch of
cells that the matrix happens to be keeping around in reserve just in case;
after all, nothing is more common than to want to cycle through all the
cells, and "for (NSCell* cell in [matrix cells])" seems an obvious way to do
that - but if [matrix cells] includes a bunch of extraneous housekeeping
cells, it doesn't work correctly.

But it won't surprise me if I get the old heave-ho "Works as intended"
response. m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Programming hot key

2009-11-04 Thread Matt Neuburg
On Tue, 03 Nov 2009 20:06:50 -0800, Eric Schlegel  said:
>
>On Nov 3, 2009, at 6:10 PM, Symadept wrote:
>
>> Hi,
>> 
>> Anybody tell me can I program a hot key which shall not block the other apps
>> responding to it.
>> 
>> Lets say I have registered hot key Command+P for some operation for my app,
>> it shall not block the other apps responding to it.
>
>You should probably use the CGEventTap API to implement this. In SnowLeopard,
you could also use +[NSEvent addGlobalMonitorForEventsMatchingMask]. In either
case, however, I believe you'll need the user to enable access for assistive
devices in the Universal Access preference pane.

But isn't the real problem that there is no API for discovering what global
hot keys are registered with the system? I've been asking for this since Mac
OS X 10.0; not only do apps need it, users need it. The system must *know*
this, since it responds to the global hot keys; so why won't it reveal this
info? m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: UIView animation docs question

2009-11-04 Thread Matt Neuburg
On Wed, 4 Nov 2009 09:17:30 -0600, Fritz Anderson 
said:
>
>On 3 Nov 2009, at 4:23 PM, lorenzo7...@gmail.com wrote:
>
>> [UIView setAnimationDidStopSelector:@selector
>> (animationDidStop:finshed:context:)];
>>
>>
>> -(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)
>> finished context:(void *)context{...}
>
>May I point out the spelling of the second part of the selector? In
>the method, it's fin_i_shed; in the argument, it's fin__shed.

Yeah, he knows.

This is the whole problem with passing things around as strings (selector
names, key-value coding, etc.); there are so many places to go wrong, and
when you do, it can be hard to debug. m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSPopUpButton, Bindings & separator items

2009-11-04 Thread Matt Neuburg
On Wed, 4 Nov 2009 11:26:16 -0500, Eric Gorr  said:
>I found this old message, but there was no answer posted and have the
>same question...
>
>http://lists.apple.com/archives/cocoa-dev/2005/Jan/msg00886.html
>
>Is there a way to add separator Items to an NSPopUpButton using
>bindings?

Here's an easy way; this is how I do it in my NotLight app.

First, #define MYMENUSEPARATORSTRING somewhere where everyone who needs to
can see it.

Now, subclass NSMenu and override as follows:

- (id )addItemWithTitle:(NSString *)aString
 action:(SEL)aSelector
  keyEquivalent:(NSString *)keyEquiv {
if ([aString isEqual: MYMENUSEPARATORSTRING]) {
id  sep = [NSMenuItem separatorItem];
[self addItem:sep];
return sep;
}
return [super addItemWithTitle:aString action:aSelector
keyEquivalent:keyEquiv];
}

Now use that NSMenu subclass where needed. The bound object uses
addItemWithTitle to construct the menu, so our overridden method will be
called and a separator item will appear wherever MYMENUSEPARATORSTRING
occurs as the title in the bound content. m.


-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How to retrieve document type?

2009-11-05 Thread Matt Neuburg
On Thu, 5 Nov 2009 11:58:02 -0800, Laurent Daudelin
 said:
>I've been searching for this but haven't found any info.
>
>I'd like to retrieve the document type of a given file and display it like the
Finder does, like "Portable Document Format (PDF)" or "Microsoft Word document".
>
>How can I do that?

Aren't you just asking for its kMDItemKind? So presumably you could get that
with MDItemCopyAttribute (assuming I'm not misunderstanding the question).

m.
-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: AHGoToPage function

2009-11-08 Thread Matt Neuburg
On Sun, 08 Nov 2009 02:20:34 +, Ian Piper  said:
>On 8 Nov 2009, at 01:47, Ian Piper wrote:
>
>> Hi all,
>>
>> I hope someone can illuminate me.
>
>Erm, I just illuminated myself. First, I was typing AHGoToPage, not
>AHGotoPage (though I think my version looks nicer). Second, I hadn't
>added the Carbon Framework. Now that I have done both, it works fine.

Although it might not do to get too confident, since in Snow Leopard there
is an acknowledged bug where use of AHGotoPage can cause Help Viewer to
crash. Apple recommends use of AHLookupAnchor as a workaround. m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Cocoa Sounds

2009-11-09 Thread Matt Neuburg
On Mon, 9 Nov 2009 14:16:14 -0500, "Sean McBride" 
said:
>On 11/9/09 10:50 AM, Jens Alfke said:
>
>>I ran into this too. A decent workaround is to preload the sound:
>>create an NSSound object for the audio file you want to play, set its
>>volume to zero, then play it. After that it's "warmed up" and will
>>play instantly.
>
>I just tried this, and it seems to work well.  One catch is that 'play'
>is asynchronous, so you have to restore the volume to non-0 in the
>sound:didFinishPlaying: delegate callback.
>
>Altogether quite annoying.
>
>And this won't help fix the same problem with NSBeep.

Correct. I'm already doing various dances to try to "prime the pump" for my
own NSSounds, but I have not found a way to "prime the pump" for an ordinary
NSBeep. m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: View swap using "push" animation

2009-11-10 Thread Matt Neuburg
On Mon, 9 Nov 2009 22:18:25 -0700, PCWiz  said:
>I want to swap out one view with another by pushing the old view aside
>to slide in a new view (the kCATransitionPush type). To use
>CoreAnimation I need to work with CALayers for my views. The problem
>is that attaching a backing layer to my window content view through
>setWantsLayer distorts everything in the view.
>
>I'm not sure if this has something to do with the fact that I'm using
>a subclass of NSWindow called MAAttachedWindow (http://mattgemmell.com/source
>), which is a HUD style transparent popup window of sorts that
>attaches to another object.
>
>I can provide screenshots of this distortion if needed.

Yes, please do.

Layers don't play well with every kind of built-in control. My solution (in
my JACTVocab application, which you can download) is to take a screenshot of
the "before" and "after" appearance of the window - so now I've got two
images - and temporarily interpose a second window in which I perform the
push transition from one image to the other. You might have to resort to
something like that. m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: questions on memory issues

2009-11-10 Thread Matt Neuburg
On Tue, 10 Nov 2009 13:41:37 -0800, John Michael Zorko 
said:
>
>Hello, all ...
>
>Firstly, I very much appreciate the help i've received here -- thank
>you very much :-)
>
>I've a debugging question. I've an issue that manifests as what
>appears to be a dangling pointer. I've a view that is loaded, and all
>is fine. This is OS 2.2.1. My understanding is that under OS 2.x, the
>view controller only releases it's view when the view controller is
>released. However, if I put a breakpoint on my view controller's -
>loadView method, it's called again sometime later (and it's view
>property is now something completely different, pointing to an
>NSArray, NSOperation or something else), without the view controller's
>-dealloc method being called beforehand. I would think that if the
>view controller had to be released, say because of a memory warning,
>that its' -dealloc method would be called. I don't know why it's not ...

The view controller's dealloc tells you if the view controller is released,
but it doesn't tell you anything about whether the *view* is released. So
your breakpoint is in the wrong place. What you want is to put a breakpoint
(or an NSLog) in the *view's* dealloc, so you can understand when that's
happening. For example, suppose your view controller's view @property is
marked "(assign)" - or nothing at all - instead of "(retain)". I would
imagine that in that case the view, whether loaded from the nib or created
in some other way, will promptly vanish as soon as it's created, kapoof
(that's the actual noise it makes, though most people can't hear it),
because nothing is retaining it. The next time the view is referred to, an
attempt will be made to load it again, but as you've discovered, we're now
pointing at garbage. Also, note that if you're loading your view from a nib
(via initWithNibName:), you're not supposed to override loadView at all. m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: boundingRectWithSize:Option: and height constraint

2009-11-11 Thread Matt Neuburg
On Wed, 11 Nov 2009 08:53:37 -0500, Bill Cheeseman 
said:
>Over the past 5 years, according to Google, many people have asked why
-[NSAttributedString boundingRectWithSize:options] does not honor the proposed
height constraint, but nobody has posted the answer. Can somebody explain this
to me?
>
>The bounding rect of myMutableAttributedString is {{0, 0}, {450.117, 1285}},
when the width is constrained to 486 and the height is not contrained (i.e.,
height is set to 0.0). When I eyeball the string in its window on the screen,
these dimensions appear to be about right.
>
>With a printing page height of 612, it should take 3 pages to print. To get the
bounding rect for the first page to print, I run this code fragment in my
printing NSView object:
>
>NSSize proposedSize = NSMakeSize(486, 612);
>NSLog(@"proposedSize: %@", NSStringFromSize(proposedSize));
>NSRect pageRect = [myMutableAttributedString boundingRectWithSize:proposedSize
options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading |
NSStringDrawingDisableScreenFontSubstitution];
>NSLog(@"pageRect: %@", NSStringFromRect(pageRect));
>
>These values are logged in the console:
>
>proposedSize: {486, 612]
>pageRect: {{0, 0}, {450.117, 1285}}
>
>Why isn't pageRect being returned as something close to {{0, 0}, {450.117,
612}? -- where the 612 page height would of course be expected to come out a
little less than 612 to accommodate the vertical line heights.
>
>Including NSStringDrawingTruncatesLastVisibleLine in options doesn't change
anything.
>
>The documentation leaves me with the impression that the whole point of this
method is to return the largest rect that will honor the size constraint by
cutting off the text at the height constraint while it is being laid out within
the width constraint. Have I misunderstood?

More like wishful thinking? I don't see anything in the documentation that
would give you that impression.

Perhaps the problem here is just a wish to avoid using the text system? It
really is not at all difficult. The text system will lay out text for you in
a container of a given size (if you don't want to use a view that already
does this for you). See "Text System Overview," "Text Layout Programming
Guide," etc.

m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Garbage collection and about windows

2009-11-11 Thread Matt Neuburg
On Wed, 11 Nov 2009 18:16:11 -0500, Ben Haller
 said:
>   This policy seems to imply that windows can live on their own,
>without a reference to them from the outside world (because the window
>list references them), but panels cannot; a panel has to be strong-
>referenced by somebody.  Somebody has to *own* it.  I don't really see
>the logic there.

The memory management policy on Mac OS X (and iPhone) *is* an
ownership-based policy, so seeing the logic isn't really important. The rule
is simple: If you yourself did not alloc or copy an instance, then that
instance is a candidate for deallocation; retain it or risk losing it. That
simplicity is good.

I doubt that mere membership in the window list causes a window to be
retained. Probably something else is doing it. For example, it might be the
nib-loading memory-management rules, or the existence of an
NSWindowController that has taken ownership of the window.

A revealing and important document in this regard is:

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Loadin
gResources/CocoaNibs/CocoaNibs.html

See esp. under Nib Object Retention. The difference between Mac OS X and
iPhone memory management policy is striking, and has made a big difference
in my life. After "mysteriously" losing the object at the far end of an
IBOutlet because I failed to retain it, on iPhone, I now retain *all* my
outlets, even on Mac OS X (where this kind of thing doesn't happen if you're
not using garbage collection). Like chicken soup, it can't hurt; and
declared properties (with a "retain" policy) make it easy to do correctly.

m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSXMLParser choking on single quotes

2009-11-12 Thread Matt Neuburg
On Thu, 12 Nov 2009 12:08:20 + (UTC), kentoz...@comcast.net said:
>I'm using NSXMLParser to parse XML output from Microsoft Word and am finding
that if a string contains a single quote, the parser is only giving me the part
of the string from the single quote onward. For example given the following
string: 
>
>
>"The topic of Jim's discussion was on the yeti crab"

But that isn't XML. Can you give an example using XML? That would make it
possible for others to reproduce and consider the actual problem. m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: boundingRectWithSize:Option: and height constraint

2009-11-12 Thread Matt Neuburg
> Date: Thu, 12 Nov 2009 04:06:17 -0500
> From: Bill Cheeseman 
> Subject: Re: boundingRectWithSize:Option: and height constraint
> 
> But I was not looking for efficiency gains, only ease of coding.

The "coding" involved here is pretty much copy-and-paste from the existing
examples - in other words, no coding at all. You have not said anything in
this thread about what your *actual* needs are (i.e. what you're trying to
print), but the text system already knows how to print lengthy styled text
without worrying about lines being "cut off" by the page bottom. m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: CALayer Transitions

2009-11-15 Thread Matt Neuburg
On Sat, 14 Nov 2009 14:58:31 -0600, Gordon Apple  said:
>I assume this should be simple, but so far I haven't found the magic
>incantation, even after reading the docs, Dudley's book, and some archives.
>
>Problem:  Layer called "contentLayer" has sublayers containing layer A,
>which is to be transitioned to layer B.  (Note: Using GC here.)  Controller
>code:
>
>-(void)transitionFrom:(CALayer*)A to:(CALayer*)B{
>
>CATransition* trans = [CATransition animation];
>trans.type = kCATransitionPush;
>trans.subtype = kCATransitionFromLeft;
>trans.speed = 0.5;
>
>[[self contentLayer] addAnimation:trans forKey:kCATransition];
>[[self contentLayer] replaceSublayer:A with:B];
>}
>
>My understanding (likely wrong) is that replaceSublayer triggers the
>necessary action to start the transition, then the animation object is
>automatically removed (default).
>
>   I get an initial transition, then on subsequent calls get layer
>replacement but no transition.  What am I missing?

Your understanding is likely wrong. :) addAnimation:forKey: on a layer
triggers the animation then and there. Look at the examples in the Animation
section of the Core Animation Programming Guide.

That, however, isn't what you want. You want the action of replacing
sublayer A with sublayer B to trigger the animation. For that, look at the
Actions section of the Core Animation Programming Guide.

For my money, the easiest way to set this up is to make self your
contentLayer's delegate and implement actionForLayer:forKey:. So, assuming
the delegation is already set up:

-(void)transitionFrom:(CALayer*)A to:(CALayer*)B {
[[window.contentView layer] replaceSublayer:A with:B];
}

- (id)actionForLayer:(CALayer *)theLayer
forKey:(NSString *)theKey {
if ([theKey isEqualToString:@"sublayers"]) {
CATransition* trans = [CATransition animation];
trans.type = kCATransitionPush;
trans.subtype = kCATransitionFromLeft;
trans.speed = 0.5;
return trans;
}
return [NSNull null]; // or whatever
}

To be cleverer about when to trigger the animation and when not, just raise
an ivar flag in self. For example, you might like to animate when certain
sublayers are added but not others. So transitionFrom would raise a flag and
actionForLayer could check that flag (in addition to checking the key).
That's why I like this approach: it's so flexible. However, there are other
ways to do it.

By the way, there is an example almost *exactly* like this in the Actions
section of the Core Animation Programming Guide. m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Performance

2009-11-16 Thread Matt Neuburg
On Sun, 15 Nov 2009 22:14:32 -0800 (PST), Chris Carson 
said:
>The application runs pretty well, and running it through the Leaks instrument
there are no leaks except for 16-bytes when the application is first starting
caused by IOUSBLib. However, looking at it in the Activity Monitor, the real
memory used starts off at 25 MB and steadily grows to 250+ MB while the virtual
memory starts off at about the same and steadily grows to about the same or
sometimes close to 500MB, over the course of several minutes. This especially
happens if I don't move the mouse for a while, or don't have the application in
focus. As soon as a move the mouse or bring the application into focus, it's as
if an autorelease pool is drained and the memory drops back down to 30-40MB real
and 30-40MB virtual. This is annoying since the application hangs for 5 seconds
or so when this memory draining is occurring. Has anyone dealt with this before?
Any ideas on what could be causing this and how to work around it?

You have already understood it. :) If you autorelease stuff (or ask the
framework to make you an autoreleased object), you are saying: Release this
when you feel like it. "When you feel like it" doesn't happen when the app
isn't getting any events in the background.

The solution is either Don't Do That (i.e. if these are objects that you
own, then release them, don't autorelease them) or (more likely) introduce
your own autorelease pool into your loop, releasing it at the bottom of the
loop or (even more likely) at the bottom of every n loops, where n is some
convenient integer.

This point is nicely covered (though rather densely, and without an example)
here:

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Memory
Mgmt/Articles/mmAutoreleasePools.html

"If you write a loop that creates many temporary objects, you may create an
autorelease pool inside the loop to dispose of those objects before the next
iteration. This can help reduce the maximum memory footprint of the
application."

m.

-- 
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


  1   2   3   >