iPhone shuffle

These days I use an iPhone as my mobile music device. I have a bit over 1800 songs on it. I usually use shuffle and had it stuck in a weird state a couple of weeks ago — it was constantly playing me just a few tracks. I usually listen for just half an hour to an hour at a time, so I don't know if it would have started looping or what, but those were basically always there for a week's worth of commutes. I finally restarted the phone and that seemed to help, but what do you know, a couple of weeks, several restarts and one operating system upgrade later, it's again playing me exactly the same tracks.

As much as I love the The Roots, honestly, at this points Adrenaline!'s "Once a-again, once a-gain..." start makes me mostly think "once again indeed."

Crashes with NSURLConnection

Speaking of Cocoa (and iPhone) programming, for a change.

Having trouble with spurious EXC_BAD_ACCESS crashes when using NSURLConnection? NSZombie giving you not very clear messages about [Not A Type retain], pointing to an address that malloc_history says has been allocated somewhere with only framework code in the call stack? See Amro Mousa's blog entry about the subject.

In a nutshell, don't send the start message to a NSURLConnection object you've initialized with a +connectionWithRequest:delegate: or -initWithRequest:delegate:. It'll break stuff.

Apple, how about a warning about this in the docs? The docs for -start say "Causes the receiver to begin loading data, if it has not already.", not "Will break your program and make you waste uncounted hours debugging if receiver has already started." Or how about preventing this in the code? Is there some scenario where you'd want to call start after the object has already started?

Various Python related things

  • Python Magazine published my article "Using Dependency Injection in Python" in their August issue. Doug Hellman saw my blog entry about DI when I was switching web hosting and managed to repost old stuff to Planet Python, contacted me to ask if I wanted to expand on it a bit, I said yes, and now I've been published. Which is nice. I basically argue in the article that dependency injection is a good idea and you don't need to buy into a framework to get many of the benefits and provide some examples on how to do it. Which seems kind of apropos, seeing as there's yet another new contestant in that area.
  • I was hacking on something I wrote in Python recently and was doing it in a pretty heavily dependency injected manner, writing tests as I was going along. It came to me that one really basic, really nice thing about Python that isn't discussed all that much is that callables are duck typed and there are multiple choices on how to implement them. When you write a function that takes as a parameter something it calls to acquire values it doesn't have to care what the thing it's been given actually is. It can be a function, a callable, a bound method, a constructor, a lambda expression or even a generator. The caller doesn't have to care. It's not a language feature that's easy to fit in a bullet point or to appreciate without using it, but it is useful.
  • I was excited to see class decorators are coming in Python 2.6. Then I realized I can't remember what I wanted to use them for when I was really frustrated by their absence, but still, it's good. I always found their absence rather puzzling.

© Juri Pakaste 2024