Posts

Posts mit dem Label "Cocoa" werden angezeigt.

WebView and ARC

Another ARC related note in my blog and as I can see a problem that maybe a couple of other coders have faced as well. I am using a custom WindowController to handle a WebView and some javascript to interact with a web page. When closing the window, the window controller should get closed. Yet, its dealloc method doesn't get called. After some digging I found out that javascript calls via the windowScriptObject block the release of the web view and thus of the window controller. Setting the value for my scripting key to nil was one solution. Yet, as soon as I called javascript functions with parameters from my windows controller, the dealloc was blocked again. Loading an empty string in the mainFrame of the WebView as soon as the window will close solved that for me. So, ARC and WebView seem to play nicely together

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.

Blocks....

SnowLeopard introduced a new feature called Blocks. I know, I am lagging behind a bit, but my users still run 10.4 (some, few only), and mainly 10.5. So I had no real need to learn all the new stuff the first day I had a SL version running. Now I am playing around with all that. While I see its power in general, I see also many scenarios in modern apps that will make life hard when using blocks - or at least larger blocks. For example bcAdmin 2 uses CoreData quite a lot in the background. Many tasks that are computation intensive (finding bat calls) will regularly access a ManagedObjectContext. Haven't played around with it, but knowing of how fragile that gets when using threads manually, I fear some of my ideas will just not work out as I expect leaving my CD stack/context in a mess. :-(

bcAdmin 2.0

My main occupation throughout the last quarter of 2009 was bcAdmin 2.0. While having some feedback by users, the main goal was not only to implement these feature requests but also make the under-workings more stable and expandable. While I think I managed to do that quite well, I also found man new problems after I thought all design and coding was more or less finished. For one thing, you not only learn when learning, but mainly learn when using the things you exercised before. Especially for CoreData I have to admit that one needs a couple of try/error cycles to get through to the inner workings. While I am now 90% content with what I have managed, still some minor things will be tweaked to bcAdmin 2.1 or so. Even more so, I have to admit, that SnowLeopard improved many things in that field. While I have to stick at least for now to 10.5 support, I would love to move on to support 10.6 only. Just for all the benefits in CoreData alone. Apart from re-doing all the inner workings I al...

Dealing with Amazon S3 and buckets

i am using Amazon S3 as storage and backup solution for a couple of years now. In the beginning only US buckets (="server space") could be allocated and when available finally, I never tested the EU buckets. Until now. For the version two dot zero of my app bcAdmin I added the possibility to upload recordings to one of our servers. That way users can send me or my partners recordings for manual analysis directly from within bcAdmin. Upload destination: Amazon S3, EU bucket. Using the ConnectionKit framework I already had managed to use ftp connections. With my EU bucket at S3 I stumbled upon problems in the beginning. Seems some libraries are still using outdated code to connect to S3. The way http requests have to be built differ from early S3 to current S3. Changes were made due to routing of EU servers. Wasn't to hard to adopt, one just had to add the bucketname in the URL path. For all framework developers out there: If possible, test US and EU servers. I foun...

saving a layer tree to an image file...

With the advent of iPhone and Leopard CALayer - or whole layer trees - often get used in favor of NSViews. The CALayer and its subclasses offer many convenient ways of getting data displayed quickly and - since we all like eye candy - with subtle and less subtle animations. Blending in or out datasets of a complex graph using a fade effect for free is just nice. While revamping bcAdmin, my biggest application so far, I decided to make use of layer trees to display calls of bats, activity diagrams and the such. After getting into the way layers are hosted, drawn and animated, I had all the tools to write classes for graphs like I never was able before. Or not that easily at least. I need a print out. ... ... which was easy to get from a NSView. Not so easy from a view hosting (in any kind) layers. The images produced with the connivence methods for printing - the ones I used all the years before - produced rather empty images... Not finding a quick solution at first, I started to write ...