Posts Tagged 'iPhone'

UDID Replacement

So as you all are panicking to get your UDID-replacing code submitted before May 1st Doomsday, might want to check out

The Developer’s Guide to Unique Identifiers

We had been warned that uniqueIdentifier was going away, and now Apple is giving us not just one but two alternatives to use. But which one should you use and when is it appropriate to choose one over the other? The documentation doesn’t answer these questions and it is left up to you to decide what is best for your applications’ purposes.

I am going to outline each of the iOS supported and deprecated unique identifier methods to explain what they do in hopes of arming you with the knowledge you need to make the right decisions…

Just in case there’s anything there that you might have overlooked so far.

Now, that article does omit the SecureUDID solution that we thought looked pretty nifty last April, so if you’re not going forward with IDFA/IDFV only, might want to give that one a look over as well.

Continue Reading →


Noticed mentions of this “ReactiveCocoa” thing popping up all around lately? Yeah, us too. Let’s take a bit of a look at what that is exactly, shall we?

ReactiveCocoa / ReactiveCocoa: “is an Objective-C framework for Functional Reactive Programming. It provides APIs for composing and transforming streams of values.”

Not feeling the excitement yet? Understandable. So what is this FRP thing exactly?

Functional Reactive Programming (FRP) is a programming paradigm for writing software that reacts to change.

FRP is built on the abstraction of values over time. Rather than capturing a value at a particular time, FRP provides signals that capture the past, present, and future value. These signals can be reasoned about, chained, composed, and reacted to.

By combining signals, software can be written declaratively, without the need for code that continually observes and updates values. A text field can be directly set to always show the current timestamp, for example, instead of using additional code that watches the clock and updates the text field every second.

Signals can also represent asynchronous operations, much like futures and promises. This greatly simplifies asynchronous software, including networking code…

If that’s a bit too abstract to get a handle on easily, NSHipster has a nice layman’s intro:

ReactiveCocoa is comprised of two major components: signals (RACSignal) and sequences (RACSequence).

Both signals and sequences are kinds of streams, sharing many of the same operators. ReactiveCocoa has done well to abstract a wide scope of functionality into a semantically dense, consistent design: signals are a push-driven stream, and sequences are a pull-driven stream…

So, it’s basically fancy-pants KVO, then? No, that’s underestimating it, check out this ReactiveCocoa: First Impressions post:

‘So what?’, I hear you say, ‘It’s a nice wrapper for KVO, big whoop’. Well, it gets better: in addition to a simply KVO API, ReactiveCocoa lets you express complex conditional behaviours.

GitHub’s example is as follows:

[[[[RACAbleSelf(self.username) distinctUntilChanged] take:3] where:^(NSString *newUsername) { return [newUsername isEqualToString:@"joshaber"]; }] subscribeNext:^(id _) { NSLog(@"Hi me!"); }];

Here’s their explanation of what’s going on:

We watch username for changes, filter out non-distinct changes, take only the first three non-distinct values, and then if the new value is “joshaber”, we print out a nice welcome.

Using KVO alone this simple isn’t possible: we would need to track and retain the value of username to compare it with the new value and keep a counter around to increment every time we receive a non-distinct value. This would certainly be more than six lines of code…

OK, so it’s like KVO, plus Cocoa Bindings, except not sucking. Well, that is pretty nifty. Definitely something to try out next time we have a complex pattern to implement!

Here’s some more discussion posts worth reading:

Input and Output

Better Code for a Better World : “… an introduction to using ReactiveCocoa to solve all of the problems currently facing mankind—a phrase I only use somewhat facetiously…”

Basic MVVM with ReactiveCocoa

And some coding samples:

ReactiveCocoa / ReactiveCocoaIO: “a framework for accessing and manipulating a file system through signals…”

ReactiveCocoa / ReactiveCocoaLayout: “a framework for describing Cocoa and Cocoa Touch layouts in a reactive way…”

uasi / AFNetworking-ReactiveCocoa “makes AFNetworking reactive.”

UIButton Edge Insets has both RAC and non-RAC implementations of button editing code.

Machx / Reactive-Cocoa-Playground: “a collection of useful and sometimes experimental ReactiveCocoa code.”


Functional Reactive Programming on iOS with ReactiveCocoa and Getting Started with ReactiveCocoa

ReactiveCocoa UIKonf 2013 presentation slides

ReactiveCocoa Essentials: Understanding and Using RACCommand

Tutorial: Building A Weather App With Functional Objective-C Programming Using ReactiveCocoa

Replacing the Objective-C “Delegate Pattern” with ReactiveCocoa

Video Introduction To ReactiveCocoa And Tutorial On Reactive Cocoa In A Data-Driven Application

ReactiveCocoa Tutorial – The Definitive Introduction: Part 1/2 and Part 2/2

Continue Reading →

Tip: Computing Tilt

Here’s an excellent tutorial on how to compute device tilt using Core Motion and quaternions:

Computing the iOS device tilt

“Quatta-whatons”, you ask? Why:

The beauty of Quaternions

If you don’t know what a quaternion is yet, please don’t be afraid by this strange word that seems right out of Star Trek.

Quaternions were first described by Hamilton in 1843 and applied to mechanics in three-dimensional space.

It eases the way we deal with the orientation of a body in a 3D space, and is better suited than the Euler angles that Apple is computing for us because of three reasons :

  • it’s easier to compose rotations or to extract values from it.
  • it avoids the gimbal lock problem.
  • and Apple provides a quaternion in the CMAttitude class instance.

And because we only want to compute the yaw we do not have to worry about the gimbal lock problem, since our goal is not to described the complete iPhone orientation in the 3D space but only the tilt…

Eyes glazing over yet? For a practical example of how to add some niftiness to your app with all this, check out

dulaccc / DPMeterView: “Gravity-aware gauge-style meter view with delightful animations.”


h/t: @romainbriche!

Continue Reading →

ImageMagick Spells

So we noticed this post Overlaying Application Version on Top of Your Icon to produce Springboard icons like this for your dev builds,


and promptly thought “Why, that is an immensely useful practice we must adopt immediately, what’s the trick?” Turns out the key is this command line:

convert -background '#0008' -fill white -gravity center -size ${width}x40 \
  caption:"${version} ${branch} ${commit}" \
  ${base_file} +swap -gravity south -composite "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/${target_file}"

Huh. We did not realize ImageMagick could do stuff like that!

For those of you who have been living under a rock the last 25 years, ImageMagick is a raster image manipulation library with a history dating back to 1987 that has been Apache-licensed open source since 1999. We haven’t really paid that much attention to it up until now, figuring there were better native alternatives available for the simple conversion and manipulation tasks we’d had the impression it was limited to, but perhaps that has been a bit of an oversight…

Here are just a few examples of what ImageMagick can do:

Examples of ImageMagick Usage shows how to use ImageMagick from the command-line to accomplish any of these tasks and much more. Also, seeFred’s ImageMagick Scripts: a plethora of command-line scripts that perform geometric transforms, blurs, sharpens, edging, noise removal, and color manipulations.

Indeed. There was actually an iDevBlogADay post about this not long ago, from the resource-creating perspective:

Tips for Mobile Devs – ImageMagick Command Line

But it didn’t mention that ImageMagick has been ported to iOS these days! Did you catch that last line of the feature list?

iOS Binary Release

~Claudio provides iOS builds of ImageMagick.

Download iOS Distribution

You can download the iOS distribution directly from ImageMagick’s repository.

Or you could go to marforic / imagemagick_lib_iphone on github too. Some pretty nifty stuff in that toolbox!

Continue Reading →

Custom Control Creation

This is a stellar walkthrough of, well, as it says,

How to build a custom control in iOS

For example, what if you want to build a control to help the user select an Angle value between 0 and 360?

A solution would be to create a circular slider and let the user drag the knob to select the angle value. This is something you’ve probably already seen in many other interfaces but nothing similar is available in UIKit.

That’s why this is the perfect example we can use to set aside UIKit and build something special. But first, here’s a sneak peek of what we are going to create…


Some nifty little CoreGraphics and trigonometry tips to boot; worth reading even if you’re already familiar with control writing.

Another topic that goes nicely with writing a control is making it support UIAppearance skinning — so along with that, check out

UIAppearance for Custom Views

In the simplest case, add UI_APPEARANCE_SELECTOR to your properties to inform others that this property can be set via an UIAppearance proxy. There are however some gotchas that are not clearly mentioned in the documentation, and it’s always interesting how something like this works behind the scenes…

Good tips there it’d take you a fair bit of confusion to sort out on your own!

h/t: iOS Dev Weekly!


robertwijas / UISS lets you use style sheets for your UIAppearance proxies.

Tutorial: How To Customize Native iOS UI Elements

Continue Reading →

The Amazing Audio Engine

We’ve mentioned before various libraries to serve as audio engines for your app, but here’s a new one which does look, indeed, amazing:

Screen Shot 2013-03-19 at 7.27.29 AM.jpg

No, that’s really not an exaggeration at all:

  • Effortless creation of live audio content with objects, blocks, or Audio Units and looping audio file players.
  • Automatic mixing of multiple audio signals with per-channel volume and pan controls.
  • Built-in support for audio filtering and effects, with support for Audio Units, blocks or object filters.
  • Rich audio input support with sophisticated multi-channel support.
  • Deep Audiobus inter-app audio system support.
  • Sophisticated system output recording and monitoring for in-app session recording or analysis.
  • Arbitrary audio format support: Interleaved, non-interleaved, mono, stereo, 16-bit, floating-point – whatever you need.
  • Built-in audio file reading and writing, with support for all Core Audio-supported formats.
  • Support for pinpoint-accurate timestamp based timing and alarm mechanisms.
  • Very light, efficient C engine, designed from the ground up for speed.
  • Fast, lock-free synchronisation between main and audio threads.
  • High-quality documentation with sample code and a developer forum.

Woah. All that and a trivial attribution-appreciated license? The generosity of the good folks at A Tasty Pixel knows no bounds!


Also check out Open Source iOS Library For Easy Low Footprint Background Audio Streaming

syedhali / EZAudio: “An iOS and OSX audio visualization framework built upon Core Audio useful for anyone doing real-time, low-latency audio processing and visualizations.”

Continue Reading →

Roundup: Debugging Goodies

So there’s been a number of interesting tools, tips, and tidbits of the fixing and fussing sort floating by recently, let’s collect them all up shall we?


PonyDebugger we’ve mentioned before but can’t do enough; network traffic debugging, Core Data browsing, view hierarchy displaying, so cool it’s downright frosty.

superdb: The Super Debugger by @jasonbrennan brings real time dynamism to your debugging:

The Super Debugger (superdb for short) is a dynamic, wireless debugger for iOS (and theoretically, Mac) apps. It works as two parts: a static library that runs built in to your app and a Mac app to send commands to the app, wirelessly. Your app starts up the debugger via this library, which broadcasts itself on your local network. The Mac app can discover these debug sessions via Bonjour and connect to them.

You can then send messages to your live objects as the app is running on the device (or Simulator). No need to set any break points. Any message you can send in code can also be sent this way. This allows you to rapidly test changes and see their results, without the need to recompile and deploy.

The debugger will even let you rapidly resend messages involving numeric values. When trying to tweak an interface measurement, for example, you can just click and drag on the value and see the changes reflected instantly on the device…

Between the two, that’s enough coolness to send global warming shuddering into reverse, doncha think?

markd2 / GestureLab is good stuff for debugging gesture recognizers.

UIView+DTDebug.m detects those annoying background drawing calls that always seem to slip in somewhere.

garnett / DLIntrospection makes examining objects at runtime convenient.

Which reminds us of the DCIntrospect UIKit interface examiner you might have forgotten our last mention of.

Did you know weak properties are not KVO-compliant? Debug usage of Objective-C weak properties with KVO.

The debugger of royalty introduces

… step one on the road to sanity: the debug proxy. This is useful when you want to find out how a particular class gets used, e.g. when it provides callbacks that will be invoked by a framework. You can intercept all the messages to the object, and inspect them as you see fit…

tomersh / NanoProfiler is a super lightweight individual function profiler.

siuying / IGWebLogger is a CocoaLumberjack logger which logs to the web in realtime.

Log Leech is a nifty-looking log formatter “Because System Logs Should be Beautiful.” Indeed.


Debugging Tips video presentation is the single best introduction to the basics we’ve seen (h/t: iosdevweekly!)

How to Use Instruments in Xcode is an excellent introduction to that, should you need one.

Intermediate Debugging with Xcode 4.5 has good stuff on leveraging breakpoints.

Xcode LLDB Tutorial introduces how to use predicates and KVC in the debugger;

Querying Objective-C Data Collections is the don’t-miss followup.

Stack-trace-dumping regular-expression-based symbolic breakpoints in LLDB

Hooked on DTrace, part 1 and part 2 and part 3 and part 4 are must-reading for when you want to get below the Instruments level. Also check the comments for pointers to good stuff like Top 10 DTrace scripts for Mac OS X and this DTrace book.

Analysing iOS App Network Performances on Cellular/Wi-Fi shows how to create HAR files so as to take advantage of its various nifty helper tools.

There’s somewhat of a certain symmetry here: going down just as far down as it’s possible to go debugging in “Assembly Dissembling” was what the first post we made after signing up to guide development of the Atimi Mobile Sports Framework was about, and after doing so from support of seven teams and two sports to thirteen teams and five sports across iOS, Android, and BlackBerry 10, it’s about time to shake things up a bit; and here we are, our first post after leaving is about debugging too! Great place for a full time job, Atimi, we encourage you to check out their positions if you’re looking for one; but we’re off now to focus on a more equity-involving opportunity. Not completely, though, a little variety on the menu is always welcome; so if you have any little bite-sized projects that need some chewing, drop us a line and we’ll see what we can fit in!


MattesGroeger / MGBenchmark for timing operations hard to profile with Instruments

This Xray Editor “The missing visual feedback tool for iOS developers” looks mighty cool.

This Spark Inspector thingy looks even more cool than that.

You can now use the Spark Inspector from Xcode, just like Instruments.

Reveal is another inspector tool.

Integrating Reveal without modifying your Xcode project

Symbolic breakpoint for dynamically linking libReveal

Tool For Quickly Launching, Deleting And Seeing Details Of iOS Simulator Apps

To avoid debugging unavailable or obsolete API usage, try DeployMate.

Debugging Smashed Memory in Obj-C

SimulatorRemoteNotifications “is an iOS library to send (fake) remote notifications to the iOS simulator.”

SimPholders: “A small utility for fast access to your iPhone Simulator apps.”

Easy To Use GUI Tool For Debugging iOS Push Notifications

Open Source Tool For Debugging iOS User Interfaces Featuring A 3D Viewer And More

Open Source Tool That Enables Code Tweaking In Running iOS Apps

schwa / “Prints the return value of the last function you stepped out from.”

Automating OS X App Test Build Distribution Across Multiple OS Versions

kyleve / gist:8213806: “Cute macro from Kyle Van Essen to provide compiler errors for key paths which do not exist.”

Open Source iOS Library For Easy Bug Reporting With Screenshots, Logging, Annotations, And More

There are Only Four Billion Floats–So Test Them All!

facebook / chisel: “Chisel is a collection of LLDB commands to assist debugging iOS apps.” “is the perfect platform for receiving information about your apps from the field.”

NSHipster on Benchmarking talks about the private dispatch_benchmark.

heardrwt/RHObjectiveBeagle “is an Objective C debugging tool that can sniff out class instances on the heap.”

Paw 2 – The Missing HTTP & REST API Tester For Mac

Continue Reading →

URL Scheme Tidbits

Been a while since we noted anything much about URL scheme fun and games around here, ’tisn’t it? To refresh your memory, here’s a couple still worthwhile posts: mentions places to find databases of app’s URL schemes;

x-callback-url described an excellent initiative for standardizing those schemes.

But unfortunately, x-callback-url hasn’t been adopted all that widely so far. But with this new library you have no further excuse not to:

tapsandswipes / InterAppCommunication

x-callback-url made easy

Inter-App Communication, IAC from now on, is a framework that allows your iOS app to communicate, very easily, with other iOS apps installed in the device that supports the x-callback-url protocol. With IAC you can also add an x-callback-url API to your app in a very easy and intuitive way.

IAC currently supports the x-callback-url 1.0 DRAFT specification

If, on the other hand, you have complicated URL schemes that you’re not interested in supporting that with, there’s another new library for you too:

joeldev / JLRoutes

JLRoutes is advanced URL parsing with a block-based callback API. It is designed to make it very easy to handle complex URL schemes in your application without having to do any URL or string parsing of any kind.

  • Simple API with minimal impact to existing codebases
  • Parse any number of parameters interleaved throughout the URL
  • Seamlessly parses out GET URL parameters and passes them along as part of the parameters dictionary
  • Route prioritization
  • Scheme namespaces to easily segment routes and block handlers for multiple schemes
  • Return NO from a handler block for JLRoutes to look for the next matching route
  • Optional verbose logging
  • Pretty-print the whole routing table
  • No dependencies other than Foundation

Look like a good pair of candidates for a mashup, don’t they?

In other news, here’s a clever tip for using URL schemes to activate experimental facilities:

Letterpress 1.4 includes experimental support for Spanish. Type in “letterpress:experimental” in Safari on your device (or just tap that link) to enable the dictionary options. You can then switch the dictionary under More / Language…

We are definitely going to start exposing things like that in our apps. Debug-related functionality is a particularly fertile field; we can think of many occasions indeed when a command like “myapp:throwupdiagnostics” would have been mighty handy indeed to stick in a support reply.

And just to remind you of another clever URL scheme trick, checking to see if they’re handled is a good way of knowing if an app is installed, as demonstrated to slick effect in a Collect Them All Feature!


Courtesy of @viticci, “People doing stuff with URL schemes:”

Convert Text Action

The URL Creation Workflow

iOS URL Schemes

Create A Local Evernote URL on the iPad with Pythonista

UTI definitions are another approach to the problem of data sharing: Using Custom File Types to import data into your iOS Apps

Open Source iOS Library Providing An In-App URL Router

Continue Reading →

Sequencer: Async Flow Control

Here’s a sweet library for getting rid of those annoyingly deeply nested block constructs:

berzniz / Sequencer

Sequencer is an iOS library for asynchronous flow control.

Sequencer turns complicated nested blocks logic into a clean, straightforward, and readable code.

Sequencer *sequencer = [[Sequencer alloc] init];
[sequencer enqueueStep:^(id result, SequencerCompletion completion) {
    NSLog(@"This is the first step");
[sequencer enqueueStep:^(id result, SequencerCompletion completion) {
    NSLog(@"This is another step");
[sequencer enqueueStep:^(id result, SequencerCompletion completion) {
    NSLog(@"This step is going to do some async work…");
    int64_t delayInSeconds = 2.0;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
        NSLog(@"finished the async work.");
[sequencer enqueueStep:^(id result, SequencerCompletion completion) {
    NSLog(@"This is the last step");
[sequencer run];

What does the above code do?

A Sequencer was created. There is no need to retain/hold-on-to-it. Trust me.

Four steps were enqueued to the Sequencer. The third step is async, but all the rest are plain sync code.

Each step finishes by calling completion() with a result object. This result is sent to the next step (in our case the result is nil).

We run the sequencer.

Note: Break the steps by just removing the call to completion(nil). Everything will be cleaned-up auto-magically.

Simple, elegant, and functional: What more could you ask for?

h/t: ManiacDev!

Continue Reading →

Review: Creating Games with cocos2d for iPhone 2

So as promised in our cocos2d survey a couple days back, we’ve been reading the latest from Packt,  Creating Games with cocos2d for iPhone 2:

9007OS_9007OS_Cocos2d for iPhone Hotshotcov.jpg.png

and why yes, we quite like the approach it takes. Most books we read go through pieces of a big project where the newbie finds themselves easily overwhelmed, or are snippets without a context so you need to be able to grasp their application on your own; what this one does is present nine complete but small enough to be easily graspable games of popular genres — and bundled them up to the App Store too, where you can check them out to see if you’re interested in seeing the code:

Pack 1 – Mole Thumper, Brick Breaker, Pool

Pack 2 – Memory, Match 3, Snake, Scrolling Shooter, Endless Runner

Pack 3 – Cycles of Light

The theory behind that is explained on the cocos2d blog here:

… Most developers learn the basics of cocos2d for iPhone v.2.0, and subsequently hit a wall. We have all these interesting classes that are really powerful, like CCLayer, CCSprite, actions, etc. How can we put these things together and make something equally interesting out of them?

That is the “gap” this book aims to fill. Rather than take the beginner’s book approach, where we spend several pages explaining what a sprite is, how it is drawn, etc. “Creating Games” skips many of the generalities and jumps right into the reason we are here: building games. This is the book I wished I had in hand when I was first exploring cocos2d for iPhone.

Class by class, method by method, the text explains the “good parts” of why we are building the code in this fashion. All the “good parts” are explained in detail: from building with Box2D to GameKit Bluetooth integration, and even how to build in “artificial randomness” into a Match 3 game, so you never run out of moves.

Each chapter is a complete game, and all source code is available as a download from the publisher’s web site. The games cover a wide variety of game types, and the games become more intricate and complex as the book progresses…

Can’t add to that really, except to observe that why yes the book is pretty much perfectly positioned to help cover that jump from reading the API to figuring out how to actually use it. So if you’re a complete newbie, we’d still recommend The iPhone Game Kit; but if you’ve got a bit of programming background but are new to cocos2d and/ot game programming, yep this is an excellent choice. Or if you’re interested in checking out the approach the author takes to the covered game genres, which are

  • Chapter 1: Memory
  • Chapter 2: Match 3
  • Chapter 3: Mole Thumper
  • Chapter 4: Snake
  • Chapter 5: Brick Breaker (with Box2D)
  • Chapter 6: Cycles of Light (iPad with Bluetooth integration)
  • Chapter 7: Pool (with Box2D)
  • Chapter 8: Scrolling Shooter (using Tiled)
  • Chapter 9: Endless Runner

One quibble you might have is that why isn’t v2.0 out of date already? Yep, but not by much, and download notes to bring it up to speed are on the author’s site. And while you’re there, check out the video. Definitely the best trailer we’ve ever seen for a programming book. (Pretty sure it’s the only trailer we’ve ever seen for a programming book, so the bar’s low there, but hey.)

So overall? Well, we like to reserve five stars for books that qualify as “absolutely essential fundamentals”, and it’s not quite that, but it is definitely a well done guide with far more coherence than you’ll find hunting down tutorials and samples on the web. Solid four stars, with the particular recommendation that if you find yourself in the position of being able to install cocos2d and run the samples but are having trouble gapping that over to getting started on your own game, this is the absolutely perfect book for you!

Continue Reading →
Page 7 of 95 «...56789...»