Archive for the ‘hacking’ Category

A common purpose

Thursday, June 19th, 2008

Ian Robinson posted a callout to any Cocoa developers in Northern Ireland (and wannabees, I presume). He wants to form a group to get together in order to dicuss Mac and iPhone development. Great stuff.

However, there’s another fledgling group of misfits meeting under the banner of Xcake.

Let’s get together, and code ! (You kinda have to sing that so it doesn’t sound *too* silly)

Push it.

Wednesday, June 11th, 2008

So, Monday saw the official announcement of the iPhone 3G. We all knew it was coming, and most of us had started budgeting in anticipation. It turned out that the budgeting may have been unnecessary, as Apple have tried to address the affordability of the device. They also announced MobileMe, the replacement for the aging .Mac service (I say aging when I really mean decrepit). That, again, had been widely predicted.

There was one announcement that was made that I didn’t hear anyone predicting; the push notification service. This is Apple’s proposed fix to the background applications problem (at least, Apple see it as a problem).

As you probably know, appplications written using the official iPhone SDK cannot be run in the background. You cannot write background tasks, servers or daemons that run concurrently on the device. Apple have continually cited battery life and dropped calls as the reasons why they would not support background tasks. That hasn’t stopped developers asking (nay, demanding) it though. So, Apple have listened, thought about it, and come up with a cool (read, over-engineered) approach, that is scalable (read, controllable) and goes most of the way (read, half-way) to meeting the requirements of developers.

The Push Notification Service (or whatever they eventually call it) is, essentially, an proxy service that accepts notifications from developers’ servers that are pushed to iPhones that have installed the developers’ applications. The developer can push badges (those cure little number thingies that tell you how many mails and texts you have waiting), notification sounds and dialogs (I guess that’s actually the ‘description’ of a dialog, along with buttons to be displayed etc.).

A couple of things to note:

  1. The notifications are tied to users.  By necessity, the notifications must be linked to users as they will only be sent if you need to receive them, i.e. you have installed an application from a developer that requires notifications. That’s going to give Apple the opportunity to collect a lot of data about users and the applications they are using. If you trust Apple, that’s not a problem.
  2. The system is only one way. OK, so full details haven’t been released yet, and I may have misunderstood what little is known, but there’s no way for the device to reply to any notifications.

The first one may not be a problem. Apple could use the data collected to simply track the most successful applications and developers. No bad thing. The second point, I see as more of an issue.

I have an idea for an application on the iPhone that requires the device to report it’s location every now and then (”Yea, you and everyone else mate”). Now, I could simply ask the user to click a button on a dialog pushed from a notification, which, at least, gives the user the option *not* to update their location if they choose. But, from a usability point of view, it blows. I’d much rather give the user a preference to turn off automatic location updates when they want some privacy, rather than bother them with periodic notifications flashing up every now and again. And I can’t have anything running to respond to notifications that come from the server, because that’s just a background task, and I’m not allowed those.

(I could, of course, just develop my app with the unoffical toolchain.)

What about a small service, running on the iPhone as a client side addition to the push notification system,  with which developers could register bundles to respond to notifications from their servers? That way, developers would effectively delegate the handling of notifications on the client side to an Apple process, keeping Apple in control, yet giving developers some of the flexibility of developing their own background services.

The full details of the service have not been disclosed, and I’m not at WWDC to hear if any further details are given. I’ll be interested to see how they deliver this one.

Snakes and cats

Tuesday, April 22nd, 2008

I have a VM running Linux on my MacBook. The main reason being that I could never get mod_python to install into Apache on Leopard. I followed all the instructions I could online. I could always get it compiled, but Apache would always puke when I tried to restart it with the module loaded.

Tonight, the breakthrough.

There are countless blog entries on building mod_python on Leopard, but why not add another one?

  • Get the source (3.3.1 is the newest at the time of writing)
  • When uncompressed, run
    ./configure --with-apxs=/usr/sbin/apxs
  • Open src/Makefile in your favourite text editor
  • Add “-arch x86_64″ to the end of line 27
  • Change line 49 to read “(APXS) $(INCLUDES) -c -Wc,”-arch x86_64″ $(SRCS) $(LDFLAGS) $(LIBS)”
  • Do the make/sudo make install dance
  • Root edit the file /usr/apache2/httpd.conf
  • Uncomment line 116 which should load mod_python.so, however, check that the module is loaded as ‘python_module’

(Update: I think line 116 was there from my last failed attempt at installing mod_python on this machine.)

The last point was the important one for me. There was a default of ‘mod_python_module’ there. Once I changed that, it all worked. I may be talking from my proverbial, but give it a go and tell me how it goes.

Travelling between fromValue and toValue

Thursday, April 3rd, 2008

Last night at XCake showed me just how much catching up I have to do if I’m going to be an active (useful) member of the MacHack community here.

So, I started with Bill Dudney’s Core Animation for OS X tonight.

I’ve only got through the first chapter so far, and one very tiny code example, but already I’m looking forward to getting deeper into the book and the subject.

The very first code example shows the way things are going. The author provides a little project that moves a picture from one point in a window to a new point, on a keypress. Then, with one change in the code, the image is animated along the path, rather than simply disappearing from one and appearing in another.

Like most things that Apple dream up, it’s all magic, and yet all perfectly logical. Instead of dealing directly with the thing you want to animate, you request it’s animator proxy. Then, instead of telling the window to move, you tell its proxy, and it’s the proxy’s job to interpolate everything from the start position to the end within the time alloted to the animation. Simple!

Actually, the animator proxy delegates (it’s amazing how often that word crops up in Mac development) the actual interpolation to an implementation of CAAnimation. The animator proxy looks up the implementation for the specific action you’re attempting (setFrame: for instance) and it does the interpolation between the fromValue (usually the current position) and the toValue (the argument passed to setFrame: in this case). Brilliant!

The intriguing part will come later when the book goes on to talk about how you write your own CAAnimation implementations are make them available to the animator proxies.

We’ll see how it goes from here (to there).

Update: Isn’t amazing how boring I can make such an exciting subject sound? Maybe I should’ve followed a career in higher education.