Software and Technology Ramblings

September 30, 2010

SQLPO -vs- CoreData

Filed under: iPhone Development — Tags: , — Doug Hays @ 10:20 pm

We are working on a legacy iPhone app that uses the awesome SQLPO to persist my objects to a sqlite database. The app doesn’t have a lot of data (100’s of rows) but, in our testing, believe that we are experiencing a bit of lag with SQLPO especially when inserting records.

So, I decided to run a super-simple benchmark to see whether the move to Core Data would be worth the pain.

I created two apps, each with a single class that would be persisted to the database several times over, one that used Core Data and another using SQLPO. The initial aim of the test was to compare these two frameworks on older iPhone hardware. But, after seeing the results on an iPhone 4, I didn’t feel the need to blow the dust off of my 1st Gen iPhone:

Time Test SQLPO Core Data
500 Record Insert 27.5s 0.43s
500 Record Update 15.13 sec 0.44 sec
10000 Record Insert 360 sec* 5.72 sec
10000 Record Update 300 sec* 5.82 sec
* Test did not finish. App crashed

So, Core Data is faster, but does it perform better with memory usage? We noticed SQLPO was a bit liberal with its memory usage, so we were glad to see Core Data’s result:

Memory Test SQLPO Core Data
Max Live Bytes 99.5 MB 2.54 MB
Idle Live Bytes 3.02 MB 1.74 MB
Time to release 63 sec 1 sec

Clearly a move to Core Data is the smart way to go and it had been on the to-do list for a future release. But, with these numbers, I think it may get a bump in priority.

September 22, 2010

UIWebView too wide after rotation from Landscape

Filed under: iPhone Development — Tags: , — Doug Hays @ 9:04 am

I had the simplest of UIWebView implementations throwing me an odd issue. It was an iPad app with a UIWebView, stretched to fill the entire screen, loaded from a local HTML file.

If the view was loaded in landscape and then rotated to portrait, the content size of the web view would remain at 1024 pixels wide even though the HTML content only took up 700px.

I finally found a helpful post that suggested I add the following inside the HEAD tag of my HTML:

<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">

That does the trick!

May 19, 2010

Twitter Status Update URL issue with URL encoding

Filed under: iPhone Development — Doug Hays @ 2:43 pm

I am developing an iPhone app that allows the user to tweet information from the app. For simplicity’s sake, I chose to use the URL method of sending the user off to Twitter to sign in and finish their status update. When I redirected the user to:

http://mobile.twitter.com/home?status=Hello%20World

The status update was dropped after the user logged in. So, I switched to:

http://www.twitter.com/home?status=Hello%20World

which looked fine even on a smaller screen. And, after the user logged in, the status message was retained. But, so was the URL encoding. Instead of “Hello World” the status would have been an unsightly “Hello%20World”.

I finally stumbled onto the fix and it’s an easy one. Just drop the www:

http://twitter.com/home?status=Hello%20World

And, now it works as expected after the user logs in.

Powered by WordPress