Support Home

KNKVC

KNKVC is an implementation of Cocoa's NSKeyValueCoding and NSKeyValueObserving in C# .NET, which is a specific implementation of the Observer pattern.

This set of classes gives Cocoa developers back a key part of their skillset when working in other languages, and everyone else a dead-simple, easy-to-use key-value coding and observing system. Most of the client-facing functionality is implemented using class extensions, meaning you can simply import the KNKVC namespace and start simplifying your code!

KNKVC Requires .NET 3.5.

Key-Value Coding

Key-Value Coding allows you to get and set values from an object without having to strongly type it. KNKVC adds the following (and more) extension methods to the Object (and therefore every) class:

Object valueForKeyPath(String key);
Dictionary<String, Object> dictionaryWithValuesForKeys(String[] keys);
setValueForKey(Object value, String key);
setValuesForKeysWithDictionary(Dictionary<String, Object> keysAndValues);

KNKVC also provides specific functionality for arrays and dictionaries - calling valueForKey on an array will return an array of it’s members’ values for that key, and setValueForKey will set the given value for the given key of each object in the array. Using KNKVC on a dictionary object will attempt to get/set the value for the corresponding key in the dictionary.

Key-Value Observing

Key-Value Observing allows an object to register as an “observer” for any given key of an object. When the object’s value for that key changes in a KVO-compliant way, the observer is notified of that change. Combined with Key-Value Coding, this allows your controllers to interact with your model without coupling the two at all.

At the moment, a property isn’t automatically KVO-compliant. To become KVO-compliant, you must call this.willChangeValueForKey(“key”); just prior to changing your value, then this.didChangeValueForKey(“key”); after. I’m working on making this completely automatic, but it might have to wait for the more dynamic features of .NET 4.0.

Downloading and Documentation

You can download the KNKVC library, Visual Studio 2008 project and documentation here. The documentation is available online here.

If you’re interested on how this was implemented, I posted an essay on the challenges and implementation on my personal blog. The post can be found here.

Dewey

Dewey is an open-source Collections editor for the Sony Reader PRS-505 (and maybe the PRS-700, but I don't have one to test). It is written in Cocoa and requires Mac OS X 10.5 or higher.

At the moment, Dewey is fairly feature-limited:

To add a book to the PRS-505 on Mac OS X, first copy the file to the /database/media/books directory on the device, then unplug it from your Mac. When the Reader has loaded, plug it back in - you will then be able to place the book into a collection using Dewey. Eventually you’ll be able to do this all in one step using Dewey, but I need to write code to parse the eBook formats to extract the title and author of the book, amongst other things before I can implement that feature.

Getting the Application

To to download the latest public build of Dewey, click here. This archive contains the application and the code used to build that version.

Dewey can update itself to the latest version automatically. To check for updates, choose “Check for Updates…” from the Dewey menu. Please note that this will update the application but not the code.

Getting the Code

The code is available on our public BitBucket repository: http://bitbucket.org/ikenndac/dewey/. Instructions for getting the latest code are included on that page.

KNAppGuide

image

KNAppGuide is a Cocoa framework for embedding "guides" into your application. Visually inspired by Apple Guide from the System 7 and 8 era, this framework brings this idea to the modern world of Cocoa.

Demo video:

Features include:

Planned features include:

Using KNAppGuide

Adding KNAppGuide to your application is simple:

To load a guide from file and present it takes an almost negligible amount of code:

id <KNAppGuide> guide = [KNAppGuide guideWithName:@“Sample Guide.plist”
resolver:[KNAppGuideBasicKVCResolver basicResolverWithBaseObject:self]];
KNAppGuideHUDPresenter *presenter = [[KNAppGuideHUDPresenter alloc] initWithGuide:guide];
[presenter beginPresentation];
[presenter release];

Downloading the Framework

Note: To build the framework, you need a working copy of BGHUDAppKit. This is a wonderful framework for HUD controls, and Interface Builder needs a copy of the IB plugin to compile the XIB files that contain the controls. If you don’t have this framework and aren’t interested in downloading it, you’ll find a pre-built (but not necessarily up-to-date) version below.

The code is available on our public BitBucket repository: http://bitbucket.org/ikenndac/knappguide/. Instructions for getting the latest code are included on that page.

You can also download version 0.3 of the KNAppGuide project below. This includes a pre-built version of the demo application and framework if you’re not interested in the code, or don’t have BGHUDAppKit on your system to compile it from the repository. However, it is strongly recommended that you use the repository as that’ll stay more up-to-date than this page.

http://www.kennettnet.co.uk/code/files/KNAppGuideDemo.zip

iPhone Browser

image

iPhone Browser is a sample project that demonstrates the AFC classes I’ve written. These classes are intended to be an object-oriented, Cocoa-friendly framework to talk to AFC devices such as the iPod touch and iPhone.

iPhone Browser is a sample project that demonstrates the AFC classes I’ve written. These classes are intended to be an object-oriented, Cocoa-friendly framework to talk to AFC devices such as the iPod touch and iPhone.

Oh, and they also happen to power the iPhone compatibility of our flagship product, Music Rescue.

The very inner workings of the code are based on MobileDevice.h taken from the community and Disk for iPhone by Allen Porter. The OO framework on top of this is the main reason for this project’s release.

Important: iPhoneBrowser (as well as more or less all of the iPhone products out there, open source or not) use the private, undocumented MobileDevice framework that iTunes uses. KennettNet Software Limited or any of it’s employees cannot be held responsible for any data loss that may occur, and this code is provided without warranty.

Also important: Deleting random files is bad. You will break stuff.

Demo Application

Code

iTunes 7.4 (ish) or higher is required, and the project was written in Xcode 3.0 on Mac OS X 10.5. The demo app uses features in the 10.5 frameworks, but the AFC classes will compile on 10.4. It shouldn’t be too hard to make the demo app work on 10.4 also.

http://www.kennettnet.co.uk/code/files/iPhoneBrowser01.zip