If you’re still debating getting the new iPhone SDK, now would be a good time to pass along some of challenges I had while operating on a iphone app. Read this now and you’ll save some headaches when plowing into the SDK.
Don’t plan on reusing much of your prior code. If you’re using a pennant MVC outline, which is most likely if you’re using Cocoa, then most of the use will necessitate major rewriting.
From my view, your models and the usage paradigm that look after them can be reused, devoid of much more work. On the other hand, the multi-touch border precludes the need for your existing snippets and controllers.
As an example, the code I used to download the data from a feed api using NSURLConnection, parse the XML into an NSDictionary and store it in a sorted NSArray was essentially copied and lacking calls from the desktop treatment. The director and view code was all new.
There are some very tight confines on recall running. You’re given in the order of 64 MB of space to work with. And that’s half of what’s allocated. If you go past that, it shuts you down abruptly. That tied with the fact that there isn’t any swap space where unused code can go to rest, makes for some pattern decisions that you haven’t had to consider in the desktop environment.
For example, let’s investigate how I coped the scrolling list of communication. In the desktop adaptation, each message in the list is an NSView, while on the phone each note is a UIView. The big difference is when these views are instantiated and freed.
On the desktop app, views are bent whenever you like there’s a new memo and they use space in memory until discarded from the list. The views don’t have a very large footprint and at the bottom of communications (NSTableView) it works much more effortlessly with real stuff. Better than some types of proxy.
The iPhone, on the other hand, uses a UITableView. This subclass of UIView has envoy methods that ask for a view to show off for each row in the register. Of the bat, you could instantiate a extreme list of views and just use the row index to pull the view out of an NSArray. But think about this. Commit and create the model a bit: it’s there so you have a possibility to instantiate views when they are in point of fact desired. If you have 2,000 names in your dealings list, and are only displaying 8 at a time, why do you need to have 1992 views killing memory?
Basically, you’ll find physically being as lazy is promising when it comes to being against distribution, and being as brutal on the cards as when it comes to freeing of those same objects.
Try to envisage a Cocoa appliance with no Boundary Engineer. This nightmare will be converted into a reality as soon as you start building your iPhone app. There are no NIBs.
I don’t think this is one of those not ready yet decisions. The process to unarchiving the bits and pieces in the NIB takes CPU cycles and memory: both tasks that are undesirable on the cell phone. And, as I declared before, you’ll find that by manually creating and killing views much more often than you do in your desktop product. And anyone who has tried to deallocate stuff from a NIB knows how hard it is.
Creating views, placing footers as subviews using NSRects, and then surroundings a bunch of properties isn’t the most sophisticated coding around, but it’s the price you pay to run on a mobile phone gadget. Just be very happy you’re working in Objective-C and not some other crappy writing.
Another thing that Cocoa developers have gotten bent out of shape with: bindings. You’ll find that all the average KVC and KVO infrastructure is expound, but it saves much less time when you have to find out all the bindings yourself with code. If you’re like me, you’ll end up just targeting the joystick at easy methods and be done with it.
The good news is that the user gui is much less messy. The bad news is that the user border is much less complex. If you have a rich desktop appliance with hundreds of skins, you’ll find that it’s hard to pick what you definitely need. Culling skin choice isn’t easy, but let’s agree it’s necessary.
One psychological takeaway fit that I’ve found practical is to ask myself if I need this trait while on foot down the boulevard or session in passage. Both are situations where there are large distractions to the task at hand. Does the feature make it easier to interact?
Luckily, not having NIBs and bindings gives you some incentive to get rid of uncalled for complexity. When it’s not easy to add that view with hundreds of joystick, you’ll think twice.
Don’t think that your desktop and mobile claim will share any look and feel. There may be slight resemblances with honor to branding, but that’s about it. Safari doesn’t look like MobileSafari beyond the same icon.
While I was improving the look and feel to my purpose, there were two areas which were tricky: show difference and close placement. Being able to read the show in all kinds of light environments means you’re going to need high contrst. In your office ecosystem, it may seem a bit showy to have a lot of dark rudiments on light backgrounds or vice versa, but once you in point of fact try to use these basics in the real world it makes wide-ranging sense.
This real world usage also makes you think about where to place controls. In one case, I positioned two buttons too close to one an alternative and found that when I used one hand to drive the UI, my thumb would often hit the wrong direction by mistake. When I was doing development in my company with the phone on my desk, I used two hands to control the UI and didn’t see this problem.
It’s likely that there will be a simulator in the iPhone SDK. Don’t wait til there’s a big following that you’ll be able to use on this pretend experiment for all your enhanced work. You have to literally live with the environment it is already in.
Tags: app development, applications, consumer, desktop app, iPhone, marketing, mobile computing, products, public use, SDK