Oct 192011
 

I fucking did it.

After, what, two years now?

I wanted to start learning iPhone programming. I had a Mac and installed Xcode. I acquired four different books on the subject. I decided, as a learning project, to create a simple app to calculate “mote pools” for my character in Exalted (don’t ask, just roll with it) and track changes in it over the course of a game session.

Almost right away I ran into a wall: how to take four user-determined numbers ranging from 1-5, programmatically determine the two with the highest values, and how to handle a case where two or more had the same value. For example, given: “3, 2, 2, 2”, how do you decide which two 2s to use?

While informative, I reached a point in each book where they just completely lost me, and none of them had an answer to my original problem. Over the course of months, I asked four different programmers I was lucky enough to meet how I might handle it. They all said the same thing: create a static array, plug in the numbers, sort it highest to lowest, and return the top two. That was all well and good but, while they all told me what to do, no one could tell me how to do it, and I didn’t know any of them well enough to make them sit down and show me how to code.

I tried, on multiple occasions, searching the Xcode documentation about NSArray, but it made my head spin because I didn’t know enough to even know what to look for. Eventually I gave up, but it’s stayed at the back of my mind and bugged me ever since. It should not have been that difficult.

Today during lunch I saw an offer on RayWenderlich.com, an iOS programming site I follow on RSS: sign up for their newsletter and get the first “epic-length tutorial” of a new series they’re running, by Matthijs Hollemans, for free. I did, but couldn’t get far in 45 minutes. Since I had the house to myself tonight, I got everything else out of the way when I got home and started working.

I got about halfway through, and had just barely finished the section on if-else statements, when the Eureka moment hit me: I didn’t need to do an array, and I didn’t have to try and compare four numbers at once. I could split them into two pairs, compare each separately, and store the highest one. If neither one was greater than the other, that meant they were equal, and I could arbitrarily take the first member of the pair and store it. Repeat for the second pair. I set the tutorial aside and spent the next two hours coding.

What follows is a mess. It’s ugly. It’s inelegant. I’m sure it could be done half a dozen ways in less than half the amount of code. It will make no sense to you unless you code. In retrospect, I should have figured it out a long time ago.

But it works, and I did it myself.

I’ll be buying the rest of those tutorials come payday.

By the way, WordPress sucks at displaying Rich Text Format.

Scary Code This Way…

Jun 212010
 

First of all, as many users are reporting, the pre-upgrade backup moved at a glacial pace; FAR slower than the non-upgrade backup I did just minutes before. After doing some research I hit upon a workaround: do a normal backup first (very important!), download the update, then cancel the installation. Go back and click Restore instead of Update. This will wipe the iPhone back to factory settings and restore it from your normal backup using the new OS version. Restoring this way is also pretty damn slow, but far faster than waiting for the upgrade backup to complete.

At long last the reboot completed and I was back in business. The phone does seem a bit more responsive than before but, since this is merely a 3G, it’s slight enough that it may just be wishful thinking on my part. Also, being a 3G, it’s lacking the major feature: multitasking. Surprisingly, it’s also lacking a minor feature: custom wallpaper on the home screen. Really, Apple? Is the horsepower of the 3GS and 4 really necessary to display a home screen background image, or was this just oversight?

Regardless, here are some of the first impressions and observations:

1. Folders: Since I wasn’t getting all the bells and whistles the newer hardware gets, this was a big one for me. I’ve managed to consolidate five screens of app icons down to 1 1/4. Now all my most commonly-used apps can all reside on the main screen in custom-named folders. Much rejoicing.

2. Camera: I still don’t have tap-to-focus, being a hardware item, but I was surprised to see that even the 3G gets the digital zoom slider. Considering the crap resolution of the camera, I don’t know how useful this will be but, hey, I can say I have it.

3. Maps: The GPS seems to lock noticeably faster and somewhat more accurately, even indoors.

4. iBooks: The first time I tried opening Winnie-the-Pooh I got an error message to the effect of “The book could not be opened because a required resource could not be located.” After the second attempt the book opened normally, but was very slow to respond for about 30 seconds while everything loaded in the background. Once all of that was completed, it ran very smoothly. The text is easy to read and the controls are intuitive, but I kept trying to pinch-zoom, which does nothing.

Adding PDF files to the phone is as easy as going to the Books tab in iTunes, and dragging the file from the Finder or desktop into that tab, then syncing the phone. Only a copy is created; the original is untouched and unmoved. After syncing, the PDF did not immediately appear on the bookshelf. After I went into the Store section and came back to the bookshelf, I now had a “Books|PDFs” button at the top of the screen. I’m not sure whether the delay was a bug, or if the app was still processing the PDF before displaying it, and I just hadn’t given it enough time.

I tested the PDF viewer with a 74MB color PDF of the Exalted core rulebook, containing two-column text, sidebars, and pictures. This book has been my litmus test for every iPhone PDF reader app I’ve tried. Nearly all of them choke on it, with the exception of GoodReader and now iBooks (sort of). As with “Winnie-the-Pooh”, it took quite awhile to finish processing the book and become responsive again. Eventually it settles down and displays everything correctly. I can pinch to zoom, and double-tapping in a text column zooms in to the width of that column, which was a pleasant surprise. Unfortunately, because of the limits of the processor and memory of the 3G, rendering each page takes an unacceptable amount of time, and I can’t imagine trying to read such a large, complex PDF on it. Even as I write this, it continues to get part way through rendering the text column before everything goes out of focus, then repeating. Smaller PDFs should be fine.

CORRECTION: Oddly, after I left iBooks then immediately went back into it and pulled up the PDF, it rendered much faster on every page, no matter how far into the book I went. Flipping pages, both manually and by using the “page scrubber” control at the bottom, still involved some horrible lag, however.

I’m sure as I continue using it I’ll discover more but, hopefully, this will all be moot in about a month when I can get the iPhone 4.

Feb 052008
 

Apple released 16GB iPhones and 32GB iPod Touches today. A 16GB iPhone is the size I was holding out for, so I could replace my phone, PDA, and iPod with one device that could hold all the music I’d actually listen to. My current 30GB iPod is just over half full, and a large chunk of it is filler that I never listen to; I just keep it around because I hate destroying information.

Shit, now I need to sell something, or someone, so I can get one.

Jan 092007
 

http://www.gizmodo.com/
http://www.macworld.com/news/2007/01/09/liveupdate/index.php

*JAW —> LAP*

It’s a smartphone.
It’s a widescreen video iPod.
It has no keyboard or stylus; it’s all touchscreen.
Cingular is going to carry them.

I just bought a Blackberry.

From Cingular.

*starts banging head on desk*

%d bloggers like this: