Slides Available from “iCloud: Lessons Learned” Talk at Seattle Xcoders

Last Thursday I gave a talk at Seattle Xcoders titled “iCloud: Lessons Learned.” I’m very grateful for the warm reception and the stunning turnout—there were over 40 attendees, many of whom asked some very good questions.

By request, I have uploaded my slides. Hopefully they will be useful.
If anyone happened to take video of the talk, please contact me at kyle dot sluder at gmail dot com.
Thanks again to Disney for hosting us and to Seattle Xcoders for inviting me to blather on about iCloud for just over an hour.

Race Condition when Moving NSDocuments to iCloud

Update: I just re-read a cocoa-dev post from last month in which Kevin Perry from Apple states the following:

I don’t see the nested uses of performSynchronousFileAccessUsingBlock: you mentioned in that code, but that’s not a problem anyway, since file access is recursive, as long as it happens synchronously within the outer-most file access block (a fact that admittedly may not be documented well anywhere).

That would certainly change things. Perhaps the reason that -relinquishPresentedItemToWriter: was deadlocking on me is because it calls -performActivityWithSynchronousWaiting:, not just -performSynchronousFileAccess? I’ll have to experiment.

Now that iCloud is out, I can finally talk about this in a public forum. Unfortunately, the cocoa-dev mailing list is down. But I really need to get this question out there, or at least written down, because it involves one of the most confusing new APIs in Lion: -[NSDocument performSynchronousFileAccess:] (or -performAsynchronousFileAccess: if you really hate your sanity).

Continue reading

NSWindowController and -[NSWindow isReleasedWhenClosed]

I noticed that the Resource Programming Guide has been updated for ARC, which prompted me to investigate something that has puzzled me for a long time: how does NSWindowController interact with NSWindow’s “convenience” method -isReleasedWhenClosed?
It turns out that NSWindowController actually calls -setReleasedWhenClosed:NO on its window as part of -setWindow:. It doesn’t matter if NSWindowController loaded the window from nib, or if it was initialized with -initWithWindow: directly.

This makes memory management of NSWindowController-owned windows saner. And nowadays, with our multi-core multi-GHz machines packed with oodles of RAM, it’s worth spending the extra bytes to create an NSWindowController to manage your windows rather than rely on the arcane -isReleaedWhenClosed method (and its equally-outmoded companion, the “visible at launch” flag in Interface Builder).

I’d really prefer if the Window nib templates assumed File’s Owner was an NSWindowController and unchecked the “Release when closed” checkbox by default. NSWindowController’s cleanup behavior means you can leave the “Release when Closed” checkbox checked but still reopen a closed window, which is misleading and probably the source of my confusion in the first place. I’ve filed this request as rdar://10349276 (also viewable on OpenRadar).

Why I Complained About “Under God”

After the President finished his speech announcing the death of Osama bin Laden, I bitched on Twitter about his citation of the Pledge of Allegiance, including the Cold War-era addition of “under God.” And I got a small bit of blowback for it. Rather than continue the complaint in 140-character pieces, I figured I’d do better to write out my thoughts in full.
I complained that despite the Pledge of Allegiance, we “are not and never have been one nation under God.” But that wasn’t my real point. I should have been clearer that my issue was with the political cynicism it exposed, and how sharply it contrasted with the frank, businesslike presentation that preceded it.

Obama knew he was addressing not just the U.S., but the entire world, including countries we have invaded, have threatened to invade, or have otherwise pressured with the implied threat of invasion. Dressing up the stage with a “Mission Accomplished” banner would have been wildly inappropriate. Instead, the President treated his audience as adults, and addressed them with facts and a plain reading of the official White House position on the affair. He demonstrated the candor that drove me to vote for him, and I was grateful.

But the President has been gearing up for the reelection campaign, and it’s started to become apparent in his speechwriting. He knows that there’s a fringe minority of voters who believe he is a secret Kenyan Muslim. But there’s a much larger group of voters who simply will not vote for a President whose religious views they feel do not sufficiently resemble their own. These voters form a base of the Republican Party, but are by no means only Republican voters.

So he’s started to play up the hints towards his Christian identity. Whereas in the past he has stressed that our nation is made up of believers and nonbelievers, and even tonight emphasized that our last decade of military campaigns has not been a war on or of creed, he chose to end tonight’s speech with two references to God: one from the Pledge, and one from himself asking that “God bless America.”

The reason this language bothers me so much is because it is a concession to these voters. Yes, the President is a politician, and he has to end his speech somehow. But many of these voters believe that the opinions of atheists (or other non-Christians) should not be considered. My own parents, at least for a time, belonged to this group. Whether it extends to disenfranchisement or merely disdain, it is a potent political force.

I suppose that as a straight white male I have it relatively easy in this country. After all, there are people who will not vote for women, and who will not just refuse to vote for gay candidates but will go so far as to incite violence against them. But the rhetoric does not allow for legitimizing these opinions. It is disheartening that our politicians will through overt or subtle action legitimize the discrimination of opinions based upon the (non-)religion of their holder.

I struggled with calling my beliefs a non-religion, even parenthetically, because I take a somewhat active stance in my belief in the lack of any supernatural power. Hence the tweet. Mostly, I think that through furthering our understanding of the natural universe, we will eventually disavow ourselves of the notion of omnipotent beings and supernatural causes. I try not to instigate arguments with believers, but I feel as little reservation about stating my beliefs as the person who tells me to have a “blessed day” or offers unsolicited prayers for my ill family members.

So it’s not just a disagreement about two words inserted into the Pledge of Allegiance to bolster anti-communist propaganda at the height of the Cold War. It’s the implication that it’s okay to believe that this is a nation governed by and for Christians. It’s seeing the ugly wheels of domestic politics poke through the facade of statesmanship. And it’s about the wisdom of referencing a deity of the Judeo-Christian tradition in the same speech that is otherwise so sensitive to the perception that the American government is waging a war against Islam on behalf of its citizens.