Posts

Es werden Posts vom 2012 angezeigt.

ARC, NSWindowController and NSDocument

For bcAdmin 3 I decided to give ARC a try and use it. For a large project like bcAdmin 3 that was a big step, and I wasn't sure in the beginning, if it was the way to go. Now and then I stumble over problems, most/all of these I could solve so far. One current one was the creation of NSWindowControllers for displaying informations in extra windows. Before ARC I was storing these in local variables of my document and was releasing them when possible or necessary. This needed some glue code I didn't like. Then I stumbled over NSDocument's -addWindowController: - which I missed completely the years before. First try was to create a local instance of my window controller, add it via the above method and when closing the window, I expected it to dealloc. It didn't... the trick was here to declare the local variable as __autoreleasing ... and now it works as expected.