Archive for February, 2008

selectable NSToolbarItems and itemIdentifiers in Leopard

Saturday, February 23rd, 2008

Maybe it’s just me, but I couldn’t figure out how to specify an itemIdentifier for a toolbar item in Interface Builder 3.0 (OS X 10.5 Leopard). So I didn’t know what to return from the toolbar’s delegate method toolbarSelectableItemIdentifiers to flag items as selectable. Nor could I just flag an item as selectable directly in IB. The default identifiers given to the items are GUIDs and completely meaningless. I’m guessing these are just oversights in the newly-minted IB. (Prior to Leopard you couldn’t define toolbars in IB at all.)

I also didn’t google any obvious hits on this topic, so here’s my community contribution for today. Specify view tags on your toolbar items in IB instead of identifiers. Then implement toolbarSelectableItemIdentifiers in your delegate to check for the tags you want.

- (NSArray*) toolbarSelectableItemIdentifiers: (NSToolbar *)toolbar
{
	// yarr. leopard be toyin' with me, yarr!
	static NSMutableArray* identifiers = nil;
	if (identifiers == nil) {
		NSArray* items = [toolbar items];
		identifiers = [[NSMutableArray alloc] init];
		for(NSToolbarItem* item in items) {
			if ([item tag] == 1 || [item tag] == 2) {
				[identifiers addObject:[item itemIdentifier]];
			}
		}
	}
	return identifiers;
}

I happened to have two toolbar items I wanted to be selectable, with tags 1 and 2. Modify to suit your needs …

The pirate-speak comment is of course critical to this method’s success.

mom, part 2 (+more stardust)

Tuesday, February 19th, 2008

It never fails to jolt me when I remember that every atom of me other than hydrogen was probably created in a star more than 5 billion years ago.

Which makes our own star more of a father than a mother—”mom” would be the previous generation of stars that fused lighter elements into heavier ones so that our humble little world could coalesce in the birthwaters of our solar system. So, the mythology has it right: the sun is Helios or Apollo, an energetic, masculine god. He’s the singular bright light and gravity well that gives us power. The earth is Gaia, the daughter of Chaos (read: dissolved stardust, supernova detritus). (Or maybe not.) Put together the energy and stability of dad and the fertility of mom and you get … reality TV! George W. Bush! Cheese-like food product! Yay!

“You are what what you eat eats, too”

So I finished reading The Omnivore’s Dilemma and quickly devoured Pollan’s next book, In Defense of Food. Quite enjoyable, but perhaps not as compelling overall. The Omnivore’s Dilemma is instructional: here’s where your food comes from, and here are some of the consequences of that. In Defense of Food is, as its subtitle says, a manifesto. Pollan says that America is caught in the grip of an ideology which is making us sick and unhappy. This ideology is called nutritionism, and it tells you that because foods are made of chemicals and you don’t know anything about chemicals or biology, you can’t possibly know what to eat or how to eat it; you need experts in food science to tell you.

In point of fact, people have been eating quite well for millennia without knowing what omega-6 fatty acids are, and have generated stores of eating knowledge called cuisines that, like anything that evolves, have been subject to natural selection. Cuisines work, and it turns out that nutritionists are often at a loss to explain why. This phenomenon has names: “The French Paradox,” “The Greek Paradox.” According to American dietary guidelines, the French, the Mediterraneans, the Inuit, the Asians … all should be terribly unhealthy, victims of heart disease, diabetes and other fat-, cholesterol-, carb-, or ingredient-X-associated Western disease. But they’re not.

Cuisines work, except the cuisine of modern-day America, which is making people fat and sick, and which is by far the most deeply enamored of nutritionism. If one wishes to positively associate an illness with a cause, that might be a better relationship to investigate than, say, that of omega-6 fats and heart disease. Hmm.

It turns out this state of affairs appears to be precipitated by the dominance of money-oriented values over any other values (big shock there), and so food is (also unsurprisingly) a political and economic issue of great magnitude. Food is one arm of the complex behemoth of our modern economy and culture with momentum far too awesome for any of us to tackle individually, but Pollan suggests that we can take back some ownership of our bodies, our relationship to food and nature, and our common sense. He states his manifesto plainly and eloquently on the cover of the book: “Eat food. Not too much. Mostly plants.” Unpacking those three sentences is what the rest of the book does, and it’s worth a read.

Coming soon: telekinesis, death, and vegetarianism …

mom, part 1

Friday, February 8th, 2008

Michael Pollan TED-Talks about plants and animals and humans. And Polyface Farm and closed-loop agriculture that generates fertility instead of depleting it.

There is an essential incompatibility between the Polyface philosophy and industrial agriculture. Pollan suggests it has something to do with the modern person/corporation’s anthropocentric insistence that we’re other than animals, and separate from nature. I tend to agree. The ecosystem is not a resource on which the economy runs. The economy runs inside the ecosystem. Duh. On the other hand, we can’t have Polyface farms in downtown Manhattan. Or can we?

I’m really loving The Omnivore’s Dilemma and there is some lengthy blog post coming out of it sometime soon. I’m in fact flying to New York tonight on a red-eye, will probably not be able to sleep, etc, so maybe then …