Snow Leopard bites me on the a$$ again

Posted by lori, Thu Dec 03 15:02:00 UTC 2009

Twice, actually.

First, there was the, I think, Ruby 1.8.7 upgrade. Suddenly, my home-grown acts_as_my_thing plugin stops working. The classes with "acts_as_my_thing" crash and burn when loading, saying that "acts_as_my_thing" doesn't exist. Crap. Now what?

Eventually I managed to find the proper incantation. I have an abstract super class for a bunch of my models. It's called LabRecord. In the file that defines my "acts_as_my_thing", I had:
LabRecord.class_eval do include Lti::Acts::MyThing end

I think there is a class-loading chicken-and-egg problem going on, so after trying a bunch of stuff like moving around "requires" in the environment.rb file, I eventually decided that I was "doin it rong", and did this instead:
class LabRecord < ActiveRecord::Base include Lti::Acts::MyThing ...

But, that wasn't the end of my day. I did say twice, didn't I? A little while later I was diddling around with svn in my Rails project, and then BOOM. 3rdRail/Subclipse couldn't read my workspace anymore:
Unsupported working copy format svn: This client is too old to work with working copy '/Users/lori/Documents/workspaces/labrador/dev2'. You need to get a newer Subversion client, or to downgrade this working copy. See http://subversion.tigris.org/faq.html#working-copy-format-change for details. I'm too tired for this shit. Sigh. At least if you follow the link, you can download the Python script which will convert your Subversion workspace back to 1.5 (Snow Leopard has SVN 1.6), and get back to it.

0 comments | Filed Under: Ruby & Rails | Tags:

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:

Pulling out your Mac app version number

Posted by lori, Wed Sep 16 23:14:00 UTC 2009

File this one under useful snippets for Mac Cocoa development. How to extract the application version number out of your app's info.plist file.


[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];

0 comments | Filed Under: | Tags:

Creating application support files on the Mac

Posted by lori, Sat Sep 05 09:04:00 UTC 2009


You are writing a Mac Cocoa application, and you know you want to store your user specific application support files in a predictable location, like ~/Library/Application Support/<Application>/. So... how exactly do we do that?

Once again, Google to the rescue, and we find the answer at Cocoa Dev Central. This will not only construct the file name for you, but it will create the directory if it doesn't exist, too.

- (NSString *) pathForDataFile { 
    NSFileManager *fileManager = [NSFileManager defaultManager]; 

    NSString *folder = @"~/Library/Application Support/MyApplication/"; 
    folder = [folder stringByExpandingTildeInPath]; 

    if ([fileManager fileExistsAtPath: folder] == NO) { 
        [fileManager createDirectoryAtPath:folder attributes: nil]; 
    }

    NSString *fileName = @"MyApplication.mysettings"; 
    return [folder stringByAppendingPathComponent: fileName];
} 

Again, an example that just works. I'm on a roll today.

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:

My cyborg name is...

Posted by lori, Mon Jun 22 12:36:00 UTC 2009

Wireless Networked Destruction Xenomorph
Get Your Cyborg Name


Because sometimes, you need to just have fun, too. BTW, My husband made me do it!

0 comments | Filed Under: | Tags:

Resizing Windoze Parallels hdd files

Posted by lori, Fri Jun 19 11:36:00 UTC 2009


Parallels provides a nice tool for resizing the file you have chosen as your hard drive for your virtual machine, called the Parallels Image Tool. Unfortunately, Windows is not quite so cooperative, and will not just recognize the resized file as a larger HDD automagically. You need to resize your partition, and Windows doesn't provide any easy ways of doing this.

Googling for a solution, I discovered this very detailed example using Gparted - the Gnome Partion Editor Tool with Parallels. Unfortunately, it is old, and when I tried it the Gparted image refused to boot cleanly, with some sort of error on ... mouse detection, I think. You should just go directly to the Gparted project at SourceForge, and find the most recent stable ISO file to download. While booting, most of the instructions from uneasysilence no longer apply to the new version of Gparted, but I just went with the defaults, and it all worked. Once GParted is up and running, then the instructions from uneasysilence are useful again.

0 comments | Filed Under: | Tags:

Who needs pagination in a blog?

Posted by lori, Mon Jun 15 16:00:00 UTC 2009


I don't really blog that often. Even when I was going at full tilt, I rarely posted more than 10-12 times a month. So... I don't care about the pagination plugin anymore. I especially don't care when it involves 3 inter-related plugins, at different/conflicting versions!

So I took the easy way out, I'm afraid. Googling for alternatives, I discovered this example pastie, which gives me the month-by-month archive in the sidebar you see now.


See? Who needs pagination?

0 comments | Filed Under: Ruby & Rails | Tags: