Sometimes it can be handy to either translate an address into a set of coordinates, or get an address from a set of coordinates. These processes are known as geocoding and reverse geocoding respectively. This Quick tutorial will go over how to do these things using location services.
This week we’re gonna check out some of the mapping functionality available in iOS 7. If you haven’t heard by now, developers now have nearly full access to 3D mapping API’s. Now, you can show you’re own 3D maps.
Hooray! Apple NDA is over on iOS 7. Which means, this is the very first iOS 7 post at NSCookbook. For the first recipe on iOS 7 we’re gonna talk about UIKit Dynamics a bit. For those of you that don’t know what it is. One word, Awesome! Dynamics is a new framework that lets you give physics inspired animation to views.
Last time we left off in our block discussion I had gone over some of the basics of blocks. How to implement them, call them, and gave a bit of insight on why they are cool. Now, there is one really big benefit to using blocks and that is Grand Central Dispatch. There are of course many other neat things you can do with blocks and we’ll briefly cover a few of those too.
- You Have already looked at Recipe 25: Implementing Blocks Part I.
So What Is Grand Central Dispatch?
Today, I’ll use wikipedia as my crutch:
Grand Central Dispatch (GCD) is a technology developed by Apple Inc. to optimize application support for systems with multi-core processors and other symmetric multiprocessing systems.
Ok this doesn’t tell us a whole bunch, but what it does tell us is that it is a technology developed for multi-core processors. All you need to know is GCD is a set of tools that Apple has provided that allow us to perform blocks serially or concurrently on various queues (which map to either the main thread or another GCD managed thread). We also have the option of doing this either synchronously or asynchronously.
- You have strong knowledge of Objective-C and Core Foundation.
- You have basic understanding of of KVC (Key Value Coding) within the Objective-C language
Many if not all developers use collection objects everyday while developing great apps, but few know about the power of collection operators. As part of KVC (key value coding), collection operators help make many routine tasks simple by eliminating and simplifying code.
Those of you still waiting on the blocks part II article, hang in there, I’ll get to it soon enough. For now I thought I would give ya’ll something short and sweet that is also really useful.
Every now and then new stuff comes along that makes our lives easier. One of the best things to come to Objective-C is the advent of blocks. Blocks can simplify callbacks, enumeration, and they have huge benefits in terms of multi-threading. At first, blocks will blow your mind. Block syntax is weird, but once you get the hang of em’ they’re actually kinda easy.
This Recipe is inspired by a recent problem I ran into and had quite a bit of trouble with it. Basically I wanted to create a shape and fill it with a gradient. Sounds pretty easy huh? well, not quite as we’ll find out shortly. While my particular application required filling a circle with an ellipse, we can create any shape. In essence we’re creating a window (shaped however we want) where the user can see only a portion of the drawing behind it.
One of the coolest things about the iPhone is it’s ability to handle audio. Since it was born out of an iPod, the iPhone handles audio quite well. In this recipe we’ll explore audio recording and playback. We’ll be creating a simple app that records a sound file and plays it back. We’re basically making a voice memo app that only saves one memo and plays it back.
This week I thought I would have a bit of fun and explore image manipulation using Core Image. This sounds like it could be pretty tough, but Apple has actually made this very easy. In this Recipe we’ll be creating a photo filter app that will let you choose a photo or take a photo using the camera and filter it.
- You know the basics of Xcode, If not, we got you covered: Familiarizing Yourself With Xcode
- You know how to create outlets and actions using the interace builder
- You have a developer account and can run this app on hardware, This will be necessary if you want to capture an image using the camera
Setting Up the Project
Setting Up the Framework
Go ahead and start with a single view controller application using storyboards and title it “ImageFilterApp”.
For this App we’ll need to use the Core Image framework. To add a framework select the top level project from the project navigator on the left and scroll down in the main window to “Linked Frameworks and Libraries”. Here you can press the “+” button to add the new framework. When the dialogue opens choose the “CoreImage.framework” and press the “Add” button.
One of the coolest things smartphones are capable of now is the ability to sense motion and orientation. The iPhone does this with the use of a 3-axis Accelerometers and Gyroscopes. In this tutorial we’re going to create an app that indicates the current G and speed of rotation. Not exactly a pretty app but still instructional.
- You have a developer account and have provisioned a device. Unfortunately we can’t simulate this stuff without hardware. Follow the Apple documentation here to get set up.
- Make Sure you head over our Github page and download the source code. NSCookbook Github Recipe 19
- You have looked over some of the past tutorials and are comfortable with creating outlets and actions from the interface builder
Setting Up the Interface
Our Interface will be pretty simple as we will be displaying 12 values. We’ll show Max and Current Acceleration and Rotation about the X,Y and Z axis’.
Start with a new single view project titled “GyrosAndAccelerometers” and make sure the storyboards are selected.
Once the new project is created, open up the storyboard and drag 25 Labels onto the view. Twelve of these labels will be our outlets that will display the output data for each axis. Rename the labels and add a button as shown in the image below: