Under The BridgeUnder The Bridge

Musings
Tilt Controls

Here’s a good article to read if you’re planning some accelerometer-based controls for your next project:

Lessons Learned in Tilt Controls

Hey, anybody who comes up with a calibration screen like this

calibrate.png

has most definitely a sense of style worthy of wholehearted approval, at the very least!

Ingredients

This looks like a handy new little tool to check out: Ingredients!

Ingredients is a free browser for Apple’s documentation. It’s still under development, but today’s beta lets you:

  • View iPhone and Mac docs
  • Search Mac-related websites
  • Filter classes/symbols by various attributes
  • Quick Search with sane sorting of results
  • use the Filter Bar to quickly jump to methods in a class

Ingredients is also open source and available on GitHub

Just booted it up briefly — love the tic-tac-toe game, guys — but it looks pretty well done. And of course that open source thing is always attractive just in case we do really want to fix something…

h/t: iOS Development Goodies!

MapKitDragAndDrop

Here’s another in the ‘handy if you need it’ category — ever want to drag and drop an MKMapView pin? Well then, MapKitDragAndDrop is for you:

MapKitDragAndDrop is designed to bring drag and drop support to MapKit on iPhone platform, with just one single lightweight DDAnnotation and DDAnnotationView, users are able to drag and drop annotation pin and get the new coordinate…

  • Support both iPhone OS 3.1.x, 3.2 and iOS 4 at the same time, in the same source code.
  • Use iOS 4 MapKit built-in draggable support (Yes, you get Retina Display high resolution support for free!)
  • Use legacy MapKit techniques to create draggable annotations on iPhone OS 3.1.x and 3.2.
  • Use Core Animation to create pin effects you saw in built-in Maps.app on iPhone OS 3.1.x and 3.2.
  • Use modern runtime, Objective-C 2.0 ABI, and LLVM 1.5 compiler.

And speaking of that last point, if you really want to be as out there on the cutting edge and all that, check out this post on necessary compiler magic:

If you wan to enable Objective-C 2.0 ABI in modern runtime (so that you can use synthesized by default feature), you need to add following flag in your $OTHER_CFLAGS:

-Xclang -fobjc-nonfragile-abi2

the tricky bit being that’s just one argument, not two as the naïve observer might suspect, so if you add your flags in Xcode you could run into issues. Yet another good argument for .xcconfig files, in our opinion.

UPDATES:

On the subject of MKMapView helpers, check out MTDirectionsKit if directions are needed!

handleOpenURL.com

Looking to take advantage of other people’s apps? Or share your capabilities? Here’s a handy guide for you:

handleOpenURL.com

We set up handleOpenURL.com because we were looking for a central place where we could find more info about the schemes other apps were using and where we could share the schemes we implemented in our apps.

Searching the Internet turned up information scattered all over the net. We thought it would be a nice thing to set up a place where this information is collected.

handleOpenURL.com is open to developers to share their URL schemes.

At handleOpenURL.com you can check if the scheme you want to implement is used by another app already out there. If not, you can add it to the index so other developers know there might be a conflict if their app will implement the same.

Furthermore you can share the capabilities of your app to other developers. E.g. if you’ve published an app which enables users to send their location to Google Latitude or which can send a message to Twitter, you can share the scheme you’ve implemented and it’s parameters that can be used with it.

Yep, sounds like a good idea. Share and enjoy!

UPDATES:

Here’s another initiative along those lines: http://wiki.akosma.com/IPhone_URL_Schemes

Facebook Graph

Well, isn’t this just insanely convenient. Monday morning we put Facebook Connect into the latest project, by Monday afternoon the beta testers were squawking their beaks off about seemingly all the issues you’re no doubt familiar with if you’ve had occasion to encounter the less than exemplary user experience which is Facebook Connect, so Tuesday morning we were grumpily coming to the conclusion that maybe it’d be better to just toss that junk completely and start in learning our way around the new stuff from Facebook …

… and what ho, with a synchronous sense of timing so superb as to border on suspicious, Tutorial Virtuoso Ray Wenderlich promptly publishes:

How To Use Facebook’s New Graph API from your iPhone App

Well, doesn’t that just beat all hollow the idea of figuring out all that authentication mumbojumbo ourselves, indeed.

And if all you’re wanting is to toss some spam up on the user’s wall and don’t really care what happens once it’s thrown, as is indeed our exact situation, here’s how to go about doing that while you’re waiting for the followup tutorials:

where kQMPrefFacebookAccessToken is the token that you got by using the login dialog from the sample project, and ASIFormDataRequest is from the ASIHTTPRequest library. Looks much simpler and better working so far; but if there’s any issues, we assure you our beta testers will have them for you. Within minutes, more likely than hours. Of course, we suppose we’d be even more stressed if they weren’t so gleefully enthusiastic about outdoing all the rest in locating the most pathologically obscure bugs possible…

UPDATES:

Part 2 is up —

How To Get a User Profile with Facebook’s New Graph API from your iPhone App

And the final Part 3 —

How To Post to a User’s Wall, Upload Photos, and Add a Like Button from your iPhone App

ARM Architecture

Here’s another should-read for you all from the fellow who did the introduction to ARM® NEON™ we mentioned earlier:

A few things iOS developers ought to know about the ARM architecture

Note particularly this bit if you did read the previous article and apply it:

If you’ve read my NEON post, you may remember that in that post I also suggested a way to do the detection and selection at runtime. If you check now, you’ll notice I have actually removed that part, and now recommend you do not use that method any more…

But that aside, the most important part (in case you haven’t run across it yet) is Thumb desirability variances:

… ARMv6 Thumb code has access to fewer registers, does not have conditional instructions, and in particular cannot use the floating-point hardware. This means for every single floating-point addition, subtraction, multiplication, etc., floating-point Thumb code must call a system function to do it. Yes, this is as slow as it sounds. For this reason, I recommend disabling Thumb mode when targeting ARMv6…

… When targeting ARMv7, however, all these drawbacks disappear: ARMv7 contains Thumb-2, an extension of the Thumb instruction set which adds support for conditional execution and 32-bit Thumb instructions that allow access to all ARM registers as well as hardware floating-point and NEON. It’s pretty much a free reduction in code size, so it should be left on…

The way that we’ve handled this is that our base .xcconfig file for a universal project compiling with 4.0+ SDK now contains

ARCHS = $(ARCHS_STANDARD_32_BIT)

GCC_THUMB_SUPPORT = YES

GCC_THUMB_SUPPORT[arch=armv6] = NO

Haven’t actually verified with a built executable that indeed those do the right thing, mind you, but it makes the Inspector panel in Xcode look like it’s set up properly, and various combinations of iPhone/iPad targeting projects seem to run ok. Of course, if you have any corrections or elucidations, please share!
h/t: iPhone Development!

Multitasking Delegation

No doubt you’ve noticed updating your old apps that if you don’t just throw up your hands in disgust and do away with it, there’s a surprising deal of complexity sorting out what to do with everything you’d stuffed in -didFinishLaunching and -applicationWillTerminate. How much complexity? Well, courtesy of Dr. Touch, this much complexity:

UIApplication_Delegate_post_4_v121.jpg

Yipes! Even if you’re pretty sure you have a handle on things, worth reading through anyway. But beware that there is one inaccuracy, to be found here:

There are only two scenarios left where your app’s applicationWillTerminate: will actually be called: if it’s build with an SDK of less than version 4.0 or if you chose to opt out of backgrounding by adding the UIApplicationExitsOnSuspend key to your info.plist.

There are actually three: running your app under 4.0 on an iPhone 3G or whatever iPod version(s?) it is that don’t allow multitasking, you will get that call as well. So “hardware can multitask” should be a decision immediately under the “SDK >= 4” decision. Other than that little quibble, good reference!

Business Models

And now, we present to you the comic relief interlude of your humble servant’s perpetual pageant of perspicacious posts:

How to make money with Android – business models

Ha! A friendly jape at our dear Android-loving friends, there. We kid, we kid. We don’t actually have any Android-loving friends. Oh dear, this really isn’t going quite right, is it. OK, deep breath, straight face…

Alright, all self-indulgent chuckling at the ingenuousness of conjoining “make money” and “Android” aside, this actually is a pretty darn solid series of posts that with appropriate buzzword substitutions are completely applicable to iOS as well, and probably there’s at least something in there to rouse some pecuniary rumination:

40 Android Business Models, Part One

40 Android Business Models, Part Two

40 Android Business Models, Part Three

40 Android Business Models, Part Four

40 Android Business Models, Part Five

40 Android Business Models, Part Six

Personally, better than two years into this iPhone thing, we’ve only explored #29 so far … that leaves quite a few to try yet!

Custom Alerts

So you need to put up something kinda sorta like an alert but custom and having a spot of trouble getting it quite right? Here’s a variety of approaches you may find of use:

UIProgressHUD replacement

A dropin replacement for the named private API, for a translucent black HUD spinner please wait type display.

Implementing a Wait “Alert”…

Another approach to imitating the private API, with some animation tips. Also note the sequel Tic-Tac-Toe Update post to imitate the GameKit peer picker.

Showing a “Loading…” message over the iPhone keyboard

How to find the keyboard view, if you want to dance on the edge of undocumented functionality.

Announcing DSActivityView

Another take on the progress displaying task.

MBProgressHUD

And yet another.

And if what you’re looking for isn’t just a HUD replacement but a full on UIAlertView replacement but with being able to add edit fields and stuff with hokey workarounds or questionable API calls, here you go:

Custom Alert Views

Should be enough in all that to sort out pretty much any alert-type functionality you have in mind; but as always, Dear Reader, if you have anything relevant we’ve missed, please comment!

UPDATE:

SVProgressHUD is reputedly a simpler and prettier MBProgressHUD alternative.

… and SVStatusHUD its cousin for orientation/volume change type HUDs.

ShareKit

So chances are you’ve had to work with some social services such as Twitter and Facebook already; but how about one library that provides

  • Delicious
  • Email
  • Facebook
  • Google Reader
  • Instapaper
  • Pinboard
  • Read It Later
  • Tumblr
  • Twitter

for images, URLs, text and files; allows offline queuing; and is MIT-licensed open source? Sounds pretty appealing, yes?

ShareKit: Drop-in Share Features for all iOS Apps

Well there you go then. From the introduction:

For developers, adding sharing features to an app is a source of dread. It takes a LOT of work for each service that you add. You have to learn each service’s API, probably learn OAuth, design and build UI to handle all the interactions of logging in and collecting information, and write code to make requests and handle all possible errors. You have to do this for every service and every service has a unique API. It makes it very difficult to add all of the services your users request.

In the iOS SDK we have access to MFMailComposeViewController. This is an Apple provided view that lets apps present an email dialog to the user. You feed it some starting values like a subject line and body content and it pops over your existing application, lets the user do their thing and goes away when they are done.

This is what I wanted in my apps. I wanted the same controller but for Twitter, Delicious, Evernote, and everything else. That’s what ShareKit is.

Yes, that certainly does look top of the list to check out for your next instance of social sharing needs, indeed!

h/t: iOS Development Goodies via ManiacDev!

UPDATES:

SimpleAuth is a nice-looking alternative to ShareKit for the use case of simply wanting to authenticate users via their social accounts.