iOS

weather app

Whether you’re new to iOS programming or a long-timer, RayWenderlich.com is a valuable resource for the iOS developer. They regularly publish tutorials, tips, tricks and other goodies that you’d be crazy to do without if you’re serious about writing apps for iDevices. In addition to articles on the site, they go deeper with their books, which are excellent.

RayWenderlich.com recently published an article titled AFNetworking Crash Course, which covers how to write networking apps using AFNetworking, a library created by the folks at Gowalla that simplifies iOS network programming. In this tutorial, you build a weather app that uses AFNetworking to get its data from the World Weather Online service. Check it out; AFNetworking’s useful, and the tutorial’s pretty nice.

In order to reach the widest possible audience, the tutorial was written for iOS 5 and earlier versions of Xcode. If you’re developing with the current version of Xcode and for iOS 6 (which accounted for 83% of all iOS traffic in North America in February), you might want to make a few changes to the code in the tutorial. I’ve listed the changes below:

Use Modern Array Notation

Here’s the old way to get at the element of an array whose index is theIndex in Objective-C:

element = [theArray objectAtIndex:theIndex];

It’s a little clunky, and as I wrote in an earlier article, Objective-C’s New NSNumber, NSArray and NSDictionary Syntaxes Mean Less “Yak Shaving” for iOS and OS X Developers, there’s a much nicer way to do it:

element = theArray[theIndex];

In AFNetworking Crash Course, where you see code like this:

daysWeather = [upcomingWeather objectAtIndex:indexPath.row];

path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"WeatherHTTPClientImages/"];

change it to this:

daysWeather = upcomingWeather[indexPath.row];

path = [paths[0] stringByAppendingPathComponent:@"WeatherHTTPClientImages/"];

Use Modern Dictionary Notation

Here’s the old way to get at the item in a dictionary whose key is theKey:

item = [theDictionary objectForKey:theKey];

Again: it’s clunky. Also again, in my earlier article, I showed the modern way to access dictionary items:

item = theDictionary[theKey];

Setting items for a dictionary used to be like this:

[theDictionary setObject:theObject forKey:theKey];

Now, it’s like this:

theDictionary[theKey] = theObject;

So, in the places where you see code like:

*array = [self.xmlWeather objectForKey:@"weather";];

change it to:

*array = xmlWeather[@"weather"];

…and where you see code like:

[self.xmlWeather setObject:array forKey:@"weather"];

change it to:

self.xmlWeather[@"weather"] = array;

Update the Deprecated Location Manager Delegate Method

If you use the code as-is with iOS 6, you’ll get an error message that looks like this:

Deprecated in iOS 6.0
locationManager:didUpdateToLocation:fromLocation:
Tells the delegate that a new location value is available. (Deprecated in iOS 6.0. Use locationManager:didUpdateLocations: instead.)

Instead of using the deprecated locationManager:didUpdateToLocation:fromLocation: method, use the current locationManager:didUpdateLocations: method instead:

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
    // locations is an array of locations where the device has recently been
    // starting with the least recent and ending with the most recent.
    CLLocation *lastLocation = (CLLocation *)[locations lastObject];

    // Fetch the weather only if the last location is less than 5 minutes old
    if ([lastLocation.timestamp timeIntervalSinceNow] < 300) {
        [self.locationManager stopUpdatingLocation];
        WeatherHTTPClient *client = [WeatherHTTPClient sharedWeatherHTTPClient];
        client.delegate = self;
        [client updateWeatherAtLocation:lastLocation forNumberOfDays:5];
    }
}

{ 0 comments }

RubyMotion Tutorial

Clay Allsop’s RubyMotion Tutorial appears to be the most complete tutorial on the topic online. If you don’t relish the idea of programming in Objective-C but want to write native iPhone apps, you should check out this tutorial and see if coding apps in Ruby with RubyMotion is for you.

If you’re feeling really ambitious, you can fork the tutorial on GitHub and rewrite or expand upon your own version.

Links

AIDE: Android Java IDE

AIDE, the Android Java IDE, lets you code apps for Android devices on an Android device. It’s fully compatible with Eclipse projects, supports the full edit-compile-run cycle and has an editor with desktop IDE features like code completion, real-time error checking, refactoring and smart code navigation. According to the description, AIDE will “turn your Android tablet with keyboard into a real development box” and will “turn your Android Phone into a small development computer to browse and touch your code on the go.”

Links

iOS Image Tricks

Adam from Dwellable, the app for finding and reviewing vacation rental homes, shares some iOS image tricks that he used while taking the iPad version of the app and converting it into an iPhone app. These tricks we necessary the app, while it ran acceptably on the iPhone 4, was unacceptable slow on older units like the iPhone 3. The tricks he discusses are:

  • Using an image pipeline to serve the right image for older iPhones, retina iPhones and iPads
  • Using spriting — instead of sending a number of images, send a single large image made up of a bunch of images
  • Using 16-bit images with older devices to conserve memory

Links

Designing for Android: Tips and Techniques

Here’s a guide for designers to help them design for Android, whose ecosystem has many combinations of OS, screen size, aspect ratio and pixel density. In combination with the design guidelines on the Android Design site, this guide will help you make beautiful, usable Android apps.

Links

{ 0 comments }

A Mobile Privacy Policy You Can Use and Customize

Here’s a set of open source mobile privacy policies that you can copy, modify and use for your own mobile apps. Created by Docracy, an online store of open legal documents, you can use them as-is, or use them as a starting point for your app’s privacy policy. Most users consider the mobile device to be more personal than their desktops or laptops (even though they’re called personal computers), and it’s expected that privacy policies will eventually be required for apps; grab these and get a head start! Best of all, Docracy lets you fork their documents GitHub-style.

Links

ManiacDev’s Catalog of Open Source iPhone and iPad Apps

ManiacDev has updated their list of iOS apps for which the source code is available — there are now 85! 67 are currently available in the App Store, and while the remainder aren’t, they were at one time and you can still get the source for all of them. There’s nothing like learning from source code for complete, released applications, and I haven’t seen a bigger collection of such for iOS. If you’re interested in the source for games only, ManiacDev has a “just the games” list.

Links

TheNewBoston.com’s 200-Episode Android Tutorial Video Series

TheNewBoston.com has a video series made up of 200 videos covering Android development. The series starts with downloading and installing the JDK, Eclipse and the Android SDK, covers a lot of ground on writing Android apps, and ends with putting an app on the market and updating it. The presentation style is extremely casual and even made me chuckle a couple of times. I think it’s a pretty good launching point: use these videos as your launching point, back them up with the Android docs, and you’ll be on your way.

Links

Making Money in the App Store in “The Next 19%”

Dave Addey does some back-of-the-envelope calculations and says that while it’s increasingly unlikely for you to get your app in the top 1% of Apple’s App Store, you’ve got decent odds for getting your app into the sweet spot of what he calls “The Next 19%”.  He says that if the numbers he’s using are representative, the iOS App Store breaks down this way:

Tier How many apps? %age of Revenue Average income per app
Top 1% 6,500 36%, or $1.75 billion $269,230
The “Next 19%” 123,500 61%, or $3.05 billion $24,696
Bottom 80% 520,000 3%, or $150 million $288

 

He writes:

With the App Store maturing, hitting that top 1% increasingly requires sizeable investment and marketing in addition to app development skills. Successfully launching a 1% app (even with sizeable investment) isn’t something you’d bet your mortgage on, and I’d go as far as to say that this top end of the store is no longer a market that’s available to small independent developers.

The next 19%, however, is definitely a viable aspiration. Most of the paid apps we’ve released have fitted comfortably within the upper bounds of this part of the graph (beating the 19% average mentioned above), and these kinds of apps are definitely within reach of small development teams or sole developers.

Links

{ 1 comment }

Some Personal Notes

As I wrote earlier, I’ve declared a bit of a summer vacation for myself, but that doesn’t mean it’s been all fun and games and loafing about. I mean there’s been some fun and games and loafing about, but there’s also been a little work as well, what with lining up some conversations about work opportunities, updating the LinkedIn profile and old-school resume and of course, learning iOS development, which is what the Vaya con iOS series of articles is all about.

So, with my trusty MacBook Pro, iPad 2 and iPhone 4S, I got to work…

Just kidding — that’s not me.

As I said, with my trusty Mac and iTools, I got to work…

Okay, enough fooling around.

This is really me. I’m at the girlfriend’s place in Tampa. She goes off to work, while I start the day with an energizing swim at the central pool that almost no one in this townhouse complex seems to use:

Sixty to eighty lengths of the pool later, I emerge, shower, get dressed and then it’s time to get cracking:

She has a desk set up in her living room, which I’ve commandeered for my studies and other work. The laptop, mouse, iPad and phone are mine; Tux, the SUSE gecko, IBM bee and Sun dolphin (alas, it’s not in the shot) are hers.

A few people asked about the Nyan Cat sticker. I bought it at — I almost hate to admit this — Hot Topic (they have good pop culture stickers), cut it into two sections and laid it carefully around the trackpad.

iTunes U’s iPad and iPhone Application Development Course

There’s a pretty interesting iPad and iPhone programming course on iTunes U taught by Stanford’s Paul Hegarty. I enjoy his lectured and have watched the first three without zoning out or dozing off, which I must say is a damned sight better than some moments in my colourful academic career. I suppose not being hung over helps.

Over the course, which was recorded as it took place in the fall term of 2011, students were expected to build two complete iOS applications, with each lecture providing more material. There are 19 lectures in the series, which also includes some supplementary sessions as well as the slides for each lecture. It’s a Stanford computer science course without the Stanford tuition — it’s free! All you need is iTunes. If you decide to subscribe, be sure to get the 2011 course, as it covers iOS 5.

Ray Wenderlich and the iOS Apprentice

While researching blogs and other sites with useful information for developers with programming experience but little or no iOS development practice, I stumbled across Ray Wenderlich’s site. It’s updated regularly with new articles about various aspects of iOS development, and there’s also a regular email newsletter. One of the enticements for subscribing is that subscribers get a free tutorial — the first part of a tutorial series called The iOS Apprentice, written by Matthijs Hollemans.

I used to do Windows Phone tutorials back when I was a developer evangelist at Microsoft, and I was curious to see how someone else did it. So I signed up and soon afterwards, I got an email with the download link for the tutorial, a zip file with the tutorial in HTML form, plus XCode project files for the completed application and all the graphics and other resources needed.

I was impressed, especially because this was free. It’s on par with the NerdDinner tutorial for ASP.NET MVC, which I called the best “chapter one” I’ve ever read.

The tutorial is huge and it’s beautiful; it looks as if it was made by Apple. If you turn it into a PDF, it becomes a 117-page book, and it covers the development of a “Bull’s Eye” game, in which you try to position a slider as close as possible to a specified target value. In the process, you learn a lot: you get an intro to programming in general and XCode in particular, setting up UI controls and responding to events, dealing with different device orientations, adding a modal screen, customizing controls with your own graphics, giving your app an icon, dealing with regular and Retina displays, deploying your app to a device and more.

The tutorial was written for people who’ve never programmed before, but it does move pretty quickly. I wonder if complete novices get stuck in the process. However, I found it easy and skipped the parts in which programming concepts were explained, focusing more on the iOS-specific parts. I didn’t find the fact that it was written for beginners a bother, and I had a lot of fun in the process of following along. I even opened another project to noodle with the concepts I was learning from the tutorial.

In fact, I had so much fun with the Bull’s Eye tutorial that I decided to spend the $54 and purchase the rest. I’m currently on part 1 of the second tutorial, in which you build a reminder list app, which covers TableView-based applications. I found The iOS Apprentice more appealing and more packed with useful information than a number of iOS development books that I’d had the chance to read over and that it’s money well-spent.

If you’ve been putting off learning iOS development for whatever reason, go sign up for the newsletter at Ray Wenderlich’s site, get the first tutorial for free and give it a try. You might be pleasantly surprised.

{ 1 comment }

AppCode’s splash screen.

In my “summer vacation” post, I talked about the tools I’d be using to learn iOS development. One of them is the obvious choice: XCode, the Apple IDE, and the standard tool for developing iPhone and iPad apps. The other is a new tool, RubyMotion, which attempts to simplify iOS development with Ruby as the programming language and Rake as the primary build tool. Each has its pros and cons, and I thought that it would be interesting to learn iOS development through these two different tools and their different approaches.

James Kovacs, Tech Evangelist for the development tool company JetBrains — the people behind IntelliJ IDEA, RubyMine and ReSharper (quite possibly the most-loved Visual Studio add-on) — read my post and kindly offered me a free licence for AppCode, their IDE for MacOS and iOS development with Objective-C. In his email, he wrote:

No strings attached. Develop the next Angry Birds with it and make your millions. Wax poetic about it on your blog. Or bitch and complain about a missing killer feature. Or ignore it entirely and use Xcode exclusively. It’s really up to you.

Thank you, James! Consider AppCode added to my set of tools that I’ll be using while learning iOS development.

AppCode’s “Quick Start” screen. Click to see it at full size.

Having spent three years in the .NET world, I’ve become acquainted with Visual Studio. It’s one of the few Microsoft products that even the most ardent Microsoft-basher will say, often through gritted teeth, beats out all the others in its field. I agree; it’s an excellent IDE, and along with the underappreciated Windows Live Writer blog editing tool, is one of those precious few Microsoft tools that is consistently a pleasure to use.

Nice as Visual Studio is, it’s made even nicer by ReSharper, which adds a whole raft of utility features to Visual Studio. It takes so much drudgery out of coding that I know a number of developers who refuse to use Visual Studio without it (and a handful of purists who disdain those who use it, saying that they’re not really coding anymore). I’ve noodled a little bit with ReSharper, and liked what I saw. At the very least, it gives me some confidence that AppCode, coming from the same vendor, might have something going for it.

AppCode’s “Create Project” window.

XCode doesn’t get the same love that Visual Studio does. You’ll find many MacOS and iOS developers who like it enough and who’ll point out that it’s improved greatly over the past little while, but even the die-hard fans will say that it’s pretty clunky in places. That’s part of the appeal of alternative tools like RubyMotion, and I was curious to see how AppCode stacks up.

AppCode’s editor window. Click to see it at full size.

A little searching took me to The Code Sheriff, Yoni Tsafir’s blog, and an article in which he compared XCode to AppCode in a number of categories. AppCode wins in a number of categories, especially in those where you are doing a lot of straight-up coding: making quick fixes, refactoring, code completion and generation, keyboard shortcuts and code inspection. In other words, the sort of stuff with which ReSharper juices up Visual Studio.

AppCode doesn’t have an interface-building tool like Interface Builder, which is no longer its own app; it’s now part of XCode. I’m going to experiment with building apps with XCode alone along with taking a hybrid approach and bouncing between XCode and AppCode. That’s not all that different from bouncing between Visual Studio for coding and Expression Blend for UI, something which I did regularly when I was the Windows Phone evangelist.

So now it’s XCode, AppCode and RubyMotion. Thanks, James and JetBrains!

{ 1 comment }

Cover of "iPhone and iPad App 24-Hour Trainer"

Okay, I’ve got the “vacation” part of my summer vacation down, and now it’s time to get down to work. By that, I mean one of things I’d been planning to do on this sabbatical — aside from flying to Tampa, then Manila, then back to Tampa — was to finally learn iOS programming. It occurred to me that I was long overdue when I got my annual renewal notice for the iOS Developer Program and realized that I hadn’t done a damned thing with it. I’ve now got the time and the motivation, so the journey begins!

I’ve decided to start with the exercises from Wrox’s iPhone and iPad App 24-Hour Hour Trainer because of the way the authors Abhishek Mishra and Gene Backlin structured the book: “Here’s a feature of iOS, here’s how it works, now here’s an app you can build and noodle with to take that feature for a spin”. Each exercise is short enough to be done in an afternoon (and many of the earlier ones are even shorter), so there’s plenty of that quick gratification that one needs when embarking on a new platform.

I’ll post regular entries about my progress and impressions of the book as I work through the exercises here on Global Nerdy. As I’m fond of saying on my blogs, “Watch this space!”

{ 1 comment }

Turning Up Where Least Expected

by Joey deVilla on June 21, 2010

ip3 forumA conference devoted to devices that run iOS might be the last place you’d think you’d see a Microsoft developer evangelist, but here I am!

I’m at iP3 Forum, “a one-day event that will explore the changing mobile landscape and the business opportunities associated with Apple’s Touch Platform (iPhone, iPad and iPod touch), as business models adapt to a market where people are always connected.” It’s organized by Interactive Ontario, a group whose mandate is to promote the development of interactive media in Ontario.

iP3 Forum has two tracks: business and technical, with some sessions common to both; if you’re curious about its sessions, take a look at the schedule.

So what am I doing here? Learning. There’s a lot to learn from the mobile app cultures of the Esteemed Competition, and I want to take those lessons (I refuse to use the Microsoft term “learnings”) back to Windows Phone developers. At the same time, I’m also reaching out to iPhone developers to convince them to add Windows Phone 7 to their mobile OS roll, and I need to know about their world. I’m even doing a little noodling with iPhone and iPad development in order to learn more. As they say, travel broadens the mind, and that holds true even for “travel” to different operating systems.

My time at iP3 Forum has been peppered with interruptions – it’s the end of Microsoft’s fiscal year, which means meetings, meetings, meetings – but I’m taking notes for those sessions I’m able to catch and I’ll post them soon.

This article also appears in Canadian Developer Connection.

{ 0 comments }