Displaying articles with tag

Interface Builder hates me - PragProWriMo

Posted by lori, Sun Nov 01 14:30:00 UTC 2009

Since I've already tried the write-a-book thing before, and I know I suck at it, I'm opting for the "blog entry a day" thing... which actually means more like "blog entry a week". I know that sounds bad, but when you consider how often I've been blogging, it's a vast improvement, so...

To get down to it, maybe it's more like I hate Interface Builder... but not really. It's just that I have not yet "become one" with my tool, and we have these little spats from time to time.

I've been fighting with an Array Controller in IB, because it has no bindings listed. If you know IB and Array Controllers, you will know why that is wrong/bad. I can't bind any content into my array, and that's a big problem. I finally noticed that the icon for my bad array controller didn't look like the icon for a different, working array controller. This was a key breakthrough. And I finally figured out what I did wrong. When I added the array controller to my XIB file, I dragged in a plain old Object, and then changed the class to be my custom NoiseArrayController. That was it. What I shoulda done - drag in a generic ArrayController object, and then change IT to be my custom class.

Simple error. Hours of frustration. So, if an Array Controller in your XIB file doesn't have any bindings, maybe you did what I did. You have to get rid of it and start over with the correct base NSArrayController. Then you'll be rockin. Sigh.

0 comments | Filed Under: | Tags:

Cocoa Sheets

Posted by lori, Wed Sep 02 15:28:00 UTC 2009

I was struggling with my Photoshop plugin again. The plugin window is modal. But then I need to pop up a modal window, in order to prompt the user for new name/description for the user-saved presets. I was puzzling and Googling, and then I stumbled across a reference to "sheets". Bingo!

This page has the best little example of sheet usage. I was able to copy/paste and then a couple of tweaks, and a couple IB bindings and it all just worked.

- (IBAction)openSheet:(id)sender
{
	[NSApp beginSheet: theSheet
			modalForWindow: theParent
			modalDelegate: self
			didEndSelector: @selector(sheetDidEnd: returnCode: contextInfo:)
			contextInfo:NULL];
}

- (IBAction)theSheetOK:(id)sender
{
	[NSApp endSheet:theSheet returnCode: NSOKButton];
	[theSheet orderOut:nil];
}

- (IBAction)theSheetCancel:(id)sender
{
	[NSApp endSheet:theSheet returnCode: NSCancelButton];
	[theSheet orderOut:nil];
}

- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
	if (returnCode == NSOKButton)
		NSBeep();
}

I really love code examples that just work.

0 comments | Filed Under: | Tags:

Interesting endless loop

Posted by lori, Wed Jul 08 14:24:00 UTC 2009

Cocoa-in-Carbon application. Note to self. Do NOT "freeze-dry" a controller object in your NIB file, especially if your controller object opens your NIB file in it's init method.

Just sayin.

0 comments | Filed Under: | Tags: