jump to navigation

Making Progress! 26 June 2009

Posted by Oliver Mason in Apple, iphone, objective-c, programming.
1 comment so far

DAY 11 and the pace is picking up. I managed to sort out two of the four tabs of the app, one including a table display of Esperanto/English dictionary entries (with the proper Esperanto diacritics), and the other one being a live-search on the English gloss entries. This one even pops up an automatic keyboard when first selected; the tab bar controller sends it a message when it has been activated. I even managed to answer a question on stackoverflow.com on that issue.

I also found somewhere a hint on how to automatically shrink the label size if the text is too long, wrote a converter from the Esperanto x-notation to unicode, etc. Really pleased! Both of these will appear here later.

One thing I don’t like too much is writing all the UITableViewDelegate methods when using a table. Quite a lot of boiler-plate code, but then, it is quite powerful. I just couldn’t be bothered writing yet another set of those methods for the final tab, the info view part. But there is nothing technically difficult with it. Objective-C is also getting easier and easier, and the auto-completion feature and API doc integration of XCode really helps. Though I think for serious code I will still use vile…

That leaves pretty much only the core part of the app: the Esperanto morphological analyser. I will implement this as a finite state machine, and working with Cocoa has given me the idea to implement it using delegates; an abstract hull which calls methods on the delegates whenever it needs to retrieve data, or match something. I have the feeling that this is pretty similar to Erlang’s OTP frameworks.

It is a really rewarding experience to see your own app on the iPhone. If only I was better at designing the tab bar icons! And I can already foresee one objection: one of the tabs has a star icon, the star being the Esperanto symbol. I think I need to change that, as the star is reserved for the ‘favourites’ meaning, and I don’t think Apple would appreciate the use of a star (even if it looks slightly slimmer) with another meaning.

More problems solved 24 June 2009

Posted by Oliver Mason in Apple, iphone.
1 comment so far

DAY 10, second part. I was really annoyed by those database errors, and built in assertions to check for the size of the file, and whether the file existed at all. I think sqlite creates a database if the file doesn’t exist, and on subsequent runs the database is then empty and failure happens.

Then I had the nice situation where the program worked in the simulator, but not on the device (I wanted to check the speed on the actual phone). Again, first the file doesn’t exist, and then it’s empty. XCode didn’t seem to copy the file over. Finally it dawned on me, as I was searching for mentions of problems with copying files into the documents folder: my database file was not in the documents folder, it was within the application bundle. I thought about copying it over when the app first starts, but then, why bother? It’s a read-only database, so all I needed to do was to change the path in the db init code, using the application bundle instead of the documents folder, and hey presto, success!

I guess the problem was that I looked at the sample code for db stuff in the iPhone development book. Here a database is created in the documents folder, and I assumed that would be where my db should reside. Confusing, but finally sorted. Now I can go to sleep in peace!

Every character is important 23 June 2009

Posted by Oliver Mason in Apple, iphone, objective-c, programming.
1 comment so far

DAY 10, and a little bit of progress. I found one error, which was about to drive me mad, until I more or less by accident stumbled over the solution on stackoverflow.com; in answering a slightly different question, Rob Napier commented on a bug in the way NSLog() was used.
NSLog(@"Returning %@ rows", [nodes count]);
Here, the -count method returns an int, but the %@ symbol expects an object. Result: a bus error. You need to use %d instead. And here was I, thinking how great it is not to bother with the old printf format codes, using the %@ way instead. I hate the primitive type/object distinction!

I then also found that I had created two superimposed Table Views (did I mention that I don’t really like Interface Builder after all?), so that my table got overwritten and looked all wrong. Now I’m struggling with getting the table to start at the first entry, not the 35th (indexPath seems to start counting sections at 1, rather than 0), and all of a sudden my database won’t work.

Preparing a straightforward SQL statement suddenly fails. I did not change that part of the code, the database file is still the same as it used to be before the error occurred, and I did tell XCode to do a full clean. Still, the error remains.

Grmph.

Tab Bar Errors 22 June 2009

Posted by Oliver Mason in Apple, iphone, objective-c, programming.
add a comment

DAY 9 and more frustration. My ViewControllers didn’t seem to be called, and NSLog messages I put in didn’t appear on the console. And the whole thing crashed without me knowing what was going on.

Having another look at my iPhone development book, I realised the first mistake: the TabBar Controller wasn’t aware of which controllers to call up for the various tabs, something you need to set up in Interface Builder. Still don’t really like that way of doing things, as the fact you’ve done it (or not, as the case may be!) is not easily transparent.

After completing the tab bar attributes, the log messages suddenly turned up, which was good, and it also doesn’t crash. Well, at least not where it used to crash. Now it crashes in the loop where I read stuff out of the SQLITE database, and it crashes after the second iteration. Wonder what the cause is. Probably memory management. Mixing Objective-C and plain C makes things a bit confusing. And I don’t like that NSString is an object you need to allocate, but NSInteger is basically just an alias for int, so a primitive data type rather than an object.

Anyway, more bug hunting coming up. It all feels terribly slow, but then I’m only spending a few hours every couple of weeks on it at the moment.

App Store Idiots 20 June 2009

Posted by Oliver Mason in Apple, iphone.
Tags: ,
1 comment so far

You have to be very careful when looking at reviews and ratings in the iPhone App Store (does ‘App Store’ need the ‘iPhone’ qualifier?). Some reviews are good and point out genuinely positive or negative issues with apps, but the majority can safely be ignored, as shown by the uselessness of their comments (‘this app is rubbish, I want my money back’) and their inability to match what they say with what they do. The number of times I have seen reviews where the reviewer wrote ‘This app gets 5 stars from me!’ when they actually gave ONE, or the reverse (‘this cr*p app gets zero stars from me’, but giving 5) is astonishing. Either those people are innumerate or incapable of keeping more than one thought in their head.

I haven’t got any hard facts, but have read somewhere that people are paid for leaving positive reviews of some apps and negative reviews of competing ones. That is about the only explanation for the number of stupid reviews that isn’t too depressing.