Archive for Apple

Leopard Upgrade Reasons

From wincent on Leopard APIs:

Some of the stuff is annoyingly good, in fact; annoying because in many cases I spent days or weeks implementing stuff myself which Apple will be offering “for free” in Leopard.

I will continue to support the older versions of Mac OS X, but only for bug fixes; most of the new feature work will go into the Leopard-only versions.

Apple is likely to continue support for their own products on at least Tiger and Leopard. This makes the case for upgrading less compelling. So far I’ve yet to see anything (aside from Time Machine) that I’m dying for in Leopard.

However, if third party applications start to ship for Leopard only, then each application is going add more weight to my desire to upgrade. This is the brilliance of the ease of programming offered by Mac OS X. Something that seems to get better with each and every release.

I’m hearing “Developers, Developers, Developers”, however this time the music is coming from Apple.

Not a good time to be stuck waiting for an API in Vista …

SVN, RSS and shell magic on Mac OS X

Bill Bumgarner has a wonderful post on how to setup an RSS feed for a SVN server. This is an interesting approach, especially given how most of my workflow is now RSS based - email, photos, news.

However, the thing that caught my attention was a little command in the midst of his shell scripting:


pbpaste > post-commit

pbpaste isn’t a command I’ve come across before, but one that I looked at and went, “Wow!”.

I’m already a fan of open and have attempted to replicate its behavior on both Windows and KDE to limited success. pbpaste is going to make me miss working on my Mac even more.

pbpaste and its cousin, pbcopy, allow you to redirect the clipboard (PasteBoard) to and from the shell respectively. One of those obvious integration things that makes life a bit easier.

Thanks Apple, you’ve made it harder again to switch away from Mac OS X, and I don’t even have Time Machine … yet.

ADC Core Data Video Tutorial

See here for details on a new tutorial on Core Data.

In the vein of Ruby on Rails style video presentations, you can download the narrated video (38Mb) and learn very quickly how to put together a Core Data application.

Note: for the bandwidth challenged, it is broken down into smaller pieces on the ADC site.

As someone who is largely self taught on the Cocoa side of things, it was instructive to watch another developer at work with Apple’s tools. Aside from learning about Core Data, I learnt some productivity improvements for using Interface Builder and XCode.

If you are writing Cocoa apps, this is well worth a watch!

Elementary Bluetooth using PyObjC

Bluetooth connectivity to devices is supported on Mac OS X using Cocoa APIs, so is possible to access from Python. Bluetooth itself opens up a large body of knowledge that I am only starting to investigate.

This article outlines some basics for using Bluetooth in Python.

Bluetooth access is achieved through two frameworks, IOBluetooth and IOBluetoothUI. Neither of these are included in PyObjC by default, so a basic wrapper class makes life easier. (see the PyObjC docs)

Add the following to IOBluetooth.py:


import objc as _objc

_objc.loadBundle('IOBluetooth', globals(),
  bundle_path=u'/System/Library/Frameworks/IOBluetooth.framework')

The loadBundle pattern is very useful, and allows the classes from any Objective C framework to be loaded into the PyObjC bridge. By putting it into a separate Python module, usage becomes less painful.

For example, the most recent device is:


>>> from IOBluetooth import *
>>> devs = IOBluetoothDevice.recentDevices_(1)
>>> devs[0].getNameOrAddress()
u'gmwils 6600'
>>> devs[0].isConnected()
1
>>>

In this case, my Nokia 6600 is still connected in AddressBook.

To create a new connection to a device, Apple provides access to their user interface for Bluetooth management. It is strongly recommended that these controls are used to provide consistency for the user and detailed error handling.

For example, selecting a service from a device with a dialog:


>>> from IOBluetoothUI import *
>>> browser = IOBluetoothServiceBrowserController.serviceBrowserController_(0)
>>> browser.runModal()
-1000
>>> results = browser.getResults()
>>> results[0].getServiceName()
u'Bluetooth Serial Port'
>>>

Note: you will need a IOBluetoothUI wrapper, similar to the IOBluetooth wrapper from earlier.

Useful documentation links:

Help creating Apple Help

Useful article (via Usable Help) about creating online help for your Mac OS X application, including how to integrate context sensitive help buttons.

Also includes links to some templates (MIT license) to get you started.