Ad

Our DNA is written in Swift
Jump

Category Archive for ‘Recipes’ rss

iPhone Downsizing

I admit it, I belong to the group of people who use their iPhone singlehandedly. That is, a single-thumb-typer. Also, I scoffed at the idea of a super-sized iPhone 6+. But I am somebody to apply the scientific method for examine the validity of your own beliefs. So I purchased and used an iPhone 6+ (Gold, 128 GB) for almost 2 months. Here’s my verdict as well as an intro do size classes.

Read more

Dismissal Completion Handler

While working on an additional section for my book, I encountered a tricky situation. Pause for a moment and ponder how you would solve this: You present a modal view controller. Some action within it communicates via delegate to the presenting view controller and this dismisses it. You need to present a new modal view controller right after the first one has animated out.

Read more

Development Pods

When integrating your own CocoaPods into your apps you often find some things you’d like to tweak in your component from within the app project/workspace. This would allow you to immediately test the fix in the context of the app. This blog explains how to work with Development Pods which allow you to do exactly that.

Read more

Understanding OAuth 1.0a

Chapter 6 in my book deals with how to build a solid wrapper around a RESTful web service and how to unit-test it. I thought I had finished principal writing on my book when I handed in chapter 7, soon too appear in the Manning Early Access Program (MEAP) for readers who have preordered.

I walk you through implementing a wrapper – using NSURLSession – for searching for CDs on Discogs by scanned barcode. Until now the Discogs search API did not require any sort of authentication, which made it ideal for this example. Then a fateful email arrived on Friday, June 20th.

Read more

Object Overlay on Video

We always welcome guest bloggers on Cocoanetics.com. This edition was prepared by Tejas Jasani and covers how to overlay objects on live video using Brad Larson’s GPUImage project.
Read more

E-Mail Validation

For the ProductLayer sign-up form I wanted to make sure that the user can only send a sign up if the email address is valid. If you google for ways to validate an email address you most often solutions involving regular expressions. But since I don’t trust a RegEx unless I know it by heart, I implemented the validation with Apple’s own NSDataDetector for links.

Read more

Forward Geocoding

There are two kinds of Geocoding which you might encounter: forward and reverse. The class doing that for you in iOS is CLGeocoder. It is both capable of doing it forward (from address to lat/long) and reverse (from geo coordinates to placemarks). For this tutorial we will build an app that lets you search for addresses and display the results individually on a map view.

Read more

Unwinding

You know the story: you have an app laid out as storyboard, want to show a modal view controller and when the user is done with it it you want to dismiss it, … or un-present it, or whatever you need to get rid of the modal VC and return. Now what about a view controller that can be both presented modally or via push onto a navigation controller?

Then it starts to get complicated. Unless you know about how to unwind. It’s actually quite awesome, but you have to use it several times because it is a little bit counter-intuitive how to implement unwinding. I’m writing this tutorial so that I myself can remember how to do it in the future.

Read more

M7 Pedometer

Apple’s iPhone 5S features a dedicated motion coprocessor, dubbed the “M7”. Probably because the M stands for Movement/Motion similar to the A in “A7” standing for … um, Apple. This coprocessor collects and analyzes data from multiple iPhone sensors and determines two interesting pieces of information:

  • the motion activity state of its user (car, walking, running, standing still) ad hoc and history
  • the number of steps taken ad hoc and history

Let’s build a functional pedometer app so that we can learn about and explore the latter.

Read more

Assuring Documentation Completeness

For your open source projects you want to make sure that pull requests you merge don’t destabilise the project. Having a large number of unit tests in combination with a Continuos Integration platform like Travis-CI helps greatly. With this setup each pull request or new branch sent to your repo triggers a build and Travis-CI will let you know if all tests pass or not.

If you annotate your headers with appledoc then you can build nice class documentation viewable that integrates with the Xcode documentation viewer or can be put on a web server as HTML.

Now what about pull requests which add new functionality but which are lacking some documentation annotations? This blog post looks into using Travis-CI for making sure documentation is also complete on pull requests.

Read more