BuySellAds.com

Read the chapters in my new book Barcodes with iOS 7 as I hand them in. Great new app opportunities await!
Our DNA is written in Objective-C
Jump

Category Archive for ‘Recipes’ rss

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

Can you Smell the iBeacon?

iBacon

iBeacons are one of the hot new topics introduced with iOS 7, though I have not seen any actual real life use case for it.

Last week I received my Developer Preview Kit from Estimote and also I have begun to research iBeacons for inclusion in the book I am currently working on. Here are my findings.

There are two words that you should know to understand the difference between the two modes of operation:

  • Monitoring - this refers to a low-power region-monitoring, you get didEnterRegion: and didExitRegion: delegate messages
  • Ranging - this means a higher-power activity where you get the signal strength from individual iBeacons and can estimate distance to them from this

Read more

Wrapping a Dynamic C-Array

For version 0.2.0 of DTMarkdownParser I needed an array that would allow me to look up the string range for individual lines of a string. My initial approach was to simple use the provided method of NSValue to wrap an NSRange in it. The problem with this approach is that as the number of ranges in the array grows so does the time needed to find a range at a higher index.

Jan Weiß of Geheimwerk suggested to replace this approach with one based on C memory allocation and searching functions. This required me to brush up on my dynamic C-array allocation skills which had become somewhat rusty from only using Objective-C objects for everything. The techniques I’ll be discussing in this blog might be of great value to you, too, if you ever find yourself needing to quickly find a scalar value (i.e. a number or struct) in a dynamically sizing array.

Read more

Blurring Views on Mac

“Frosted Glass” abounds on iOS 7 and this new look is the new “Corinthian Leather”. Apple has often used design ideas from their mobile OS and let them inform UI design on OS X. This begs the question: where is frosted glass on Mac?

Mac developer Raffael Hannemann offered to do a guest tutorial for Cocoanetics.com demonstrating how to achieve the same view blurring effect on Mac, where you are much less constrained by the GPU performance. On Mac the necessary ingredients for view blurring are readily available.

On iOS Apple kept the necessary APIs for blurring private for the time being because of a severe performance problem that goes hand in hand with live Gaussian blurring. Raffel’s blog post after the break.

Read more

Xcode Coverage

Code Coverage is described on Wikipedia as:

… a measure used to describe the degree to which the source code of a program is tested by a particular test suite. A program with high code coverage has been more thoroughly tested and has a lower chance of containing software bugs than a program with low code coverage.

Less bugs? Yes, please!

Read more

Travis CI For Pull Request Validation

If you have an project that is accepting code contributions then you will want to make sure that those well-meaning additions don’t break existing functionality. Services like GitHub allow you to review such pull requests via their colored diffs or even give instructions as to how to manually pull the commits into a local branch for evaluating this.

But there is a limit that is quickly being reached if you need to check all those pull requests manually. Even worse, this is a mundane task, usually trying out if the targets build and running the unit tests. Repetitive tasks like this are boring and thus nobody can be faulted for starting to neglect them.

In this blog post I will explain how to set up Travis-CI to have all pull requests be automatically checked for you. You will know for each pull request if merging it into your develop branch would break the build or unit tested functionality.

Read more

Variable-Sized Items in UICollectionView

UICollectionView was added last year with iOS 6 and to this date I had no real chance to get acquainted with it since most of my apps were still supporting iOS 5. Doing a fresh app only supporting the latest iOS version finally allowed me to dig into it and share the journey with you.

The special scenario we want to look at today is how we could configure variable-sized collection view cells for items like tags. We want to have the cells adjust their size automatically based on the tag string and ideally we don’t want to have to write any layout code for determine the needed sizes.

Please forgive if the following has a few places where I stumbled. It is these temporary snags that I believe you learn from the most, so I left them in the final article.

Read more

Block-Based Logging Replacement for NSLog

It became apparent that we should have a standard method for logging in our frameworks. Some of use are happily using Cocoa Lumberjack in product apps, but not everybody might share this test. So there was a need to have some sort of looking hooks in our shared library code. This would allow everybody to hook up his own favorite logging framework or simply use NSLog.

In this blog post I am explaining the rationale behind DTLog, new in DTFoundation as of version 1.5.1.

Read more