Fruits of the iPhone posts

An avid reader of this blog (i.e. no one) will have noticed that lately there have been quite a few posts about iPhone development.

Well, I am pleased to announce (on behalf of Zemobo) that Zemobo Rugby has now launched on the iTunes App Store. It ties in with Zemobo’s Rugby Picks app on Facebook.

You can download it from http://bit.ly/98xEo3. It’s free!

Modal view controllers and recursion causing stack overflow

Ironically, it was this post at Stack Overflow that helped me solve this problem!

There appears to be a bug (either in the iPhone SDK or my understanding of it) that if you dismiss a modal view controller with animation using UINavigationController’s dismissModalViewControllerAnimated, it will cause some sort of weird recursion that causes a stack overflow (over 4000 frames were in the stack when it crashed, and it took a split second for it to fill up in the Simulator) if you then want to display the modal view controller again using presentModalViewController.

It turns out it’s the animation on dismissal that’s causing the problem. If I have dismissModalViewControllerAnimated:NO instead of YES, the subsequent redisplay of the view works fine.

OpenID and iPhone apps

I am trying to find an OpenID implementation that is similar to the way that Facebook Connect’s login mechanism works on the iPhone. I can’t find anything, which is very surprising.

Does anybody know of an open source OpenID consumer implementation for iPhone OS? And if you don’t know of one, are you looking for one?

If I can’t find one, I am going to have to write my own, and it’s something that I think would do well to be open sourced, so if you are interested, please post a comment.

Skype for Mac Mood Message Feed

Why isn’t anybody writing about the “Mood Message Feed” in Skype for Mac 2.8? This version appears to have been out for a month now. I Googled it to see whether it was a Mac-specific thing or if the real version has it as well and I just haven’t updated to the latest version. There were 4 results (not including the ones that Google hid).

It says it’s a pseudo chat, showing the mood updates that your contacts make. It’s kind of like the Facebook News Feed (or whatever they are calling the home page this week). The top result talks about sending your mood messages to Twitter, so I guess this Mood Message Feed is a way for Skype to try and stay relevant in the “Twitter age”.

Why is the escape key labelled “esc” on the Mac keyboard but as a circle with an arrow pointing out of it in menus?

I have reluctantly bought a MacBook Pro so that I can develop iPhone applications as well as Android, and was searching for this mysterious key so that I could get Xcode to autocomplete for me.

Turns out the circle with a diagonal arrow pointing out of it key is actually the escape key.

Why make things so difficult, Steve?

Entity Framework 4 many-to-many

I had another problem with EF4 today. Code that worked fine in .NET 3.5 didn’t work after I regenerated the entity model using Visual Studio 2010.

I found an answer, again on Stack Overflow: http://stackoverflow.com/questions/2243618/how-do-you-insert-or-update-many-to-many-tables-in-net-entity-framework

It turns out that the generator decided that one of my foreign keys in an associative table should have a StoredGeneratorPattern of Identity, meaning it thought it was an identity column. When it isn’t.

But updating the XML as suggested in the answer above fixed it. So that’s good.

1..0 or 1 relationships in Entity Framework

I came across this problem today when migrating a project from VS 2008/.NET 3.5 to VS 2010 RC1/.NET 4.0. I don’t actually think it’s a VS 2010 thing, though.

I have two entities A and B. There is a navigation property on A, and it can have either one or no instances of B. B’s foreign key is to A’s primary key (obviously) but B also has its own primary key. In the database, B has a unique index on that foreign key column, which will enforce the rule.

The problem when upgrading to VS 2010 occurred because I clicked the “Include foreign key columns in the model” check box when generating the model from the database. (I regenerated it because the tools might be better in 2010 so figured I should start from scratch.) That’s where my problem came from. The entity model designer wouldn’t let me change the navigation property and associated relationship from 1..* to 1..0 or 1, because the relationship had to be between the entities’ keys for that to work.

The problem only happens when you generate the model with foreign keys as their own columns. I regenerated it so that foreign key columns weren’t generated (the foreign keys were represented only as their navigation properties) and it worked fine, as it did in VS 2008.

I found this answer here: http://stackoverflow.com/questions/2141328/unique-keys-not-recognized-by-entity-framework/2326859#2326859

Hopefully this might be of some help to someone else!

Width of grouped UITableViewCell

I am working on some iPhone development at the moment. I have built a cell for a UITableView in Interface Builder. The cell was a bit too wide for the cell in my table view, and I realised it was because the cell in the NIB is full width but I am loading it into a grouped table view.

I didn’t want to have to measure it myself so I searched for the width. Couldn’t find it. So I measured it myself. And put it here. So maybe I will start getting a few more visits to this page from now on!

The magic number is…

300

The width of a grouped UITableViewCell is 300 pixels.