About mikett

Here are my most recent posts

iOS Programming Recipe 4: Using NSURLConnection

URL Requests

Making URLS requests on the Mac is as simple as

  1. open terminal.app
  2. then typing the following

$ curl https://alpha-api.app.net/stream/0/posts/stream/global

This retrieves the APP.NET global stream. If you are not familiar with APP.NET, it is a Twitter like service that sports an open api, similar to how Twitter used to be.

The result of running curl is a large JSON string representing the afore mentioned global stream as shown below

curl result

Unfortunately making URL requests in your iOS application isn’t quite this easy, but fortunately NSURLConnection does most of the heavy lifting for you.

NSURLConnection

The NSURLConnection class reference, located on Apple’s developer website has the following description

An NSURLConnection object provides support to perform the loading of a URL request. The interface for NSURLConnection is sparse, providing only the controls to start and cancel asynchronous loads of a URL request.

Which basically says NSURLConnection is used to perform URL requests, but how do you create the actual requests?

NSURLRequest to the rescue!

[Read more…]

iOS Programming Recipe 2: Skinning UIButton

Before You Begin

This recipe uses resizable graphics that were generated using Opacity which was the topic of another of our posts, Developer Tools – Opacity. If you are following along you can download both the 1x and 2x graphics here.

Skinning UIButton

I have seen many different approaches to creating custom looking UIButtons

  • UIButton subclass implementing drawRect
  • Drawing the background images once, then caching and reusing
  • creating images asset for each button size

While each of these methods may technically work, the best method is to use resizable image assets. Using resizable assets will allow you to take full advantage of UIKit and the performance enhancements it has to offer.

iDevices these days come in many shapes an sizes, retina and non-retina screens, ect, so it is important that you create assets at different resolutions so your application looks great on all of them!

Step 1: Setup a UIButton

  • Create a new Xcode project using the single view application template for iOS or use an existing application if you have one.
  • Open ViewController.xib and drag two UIButton’s from the object pane into your view, your view should look like the one below

ViewController_image

  • In Interface Builder, open the Attributes Inspector Option+CMD+4, then select the second button, change the Type property to Custom as shown below [Read more…]

Development Tools – Opacity

Assumptions:

  1. It isn’t required, but it will be helpful if you are familiar with layer based image editing or have experience with a graphics editing program such as Adobe Photo Shop

Getting Started

A important aspect of developing apps for iOS or OS X is creating a great User Interface. Even if your app has all the latest and greatest functionality, you are going to have a hard time getting anybody to use it if it is lacking in the UI department,.

Opacity to the rescue!

Opacity is a layer based vector graphics application for the Mac that makes designing graphics for your app a breeze. Opacity has built in templates for skinning buttons, creating 1x and 2x resolutions non-retina & retina devices, and many other time saving features as you will see!

Step 1: Download Opacity

Currently (as of this writing) Opacity is not available through the Mac App Store and I’m not sure if the developer has any plans to add it any time soon, however it can be downloaded at http://likethought.com/opacity/. I recommend starting with the trial version (free), but the full version will be necessary to remove a pesky watermark from your exported images (currently the full version is $89.99).

Additionally, there is a great video tutorial on the home page that I would recommend watching before moving on to Step 2.

Step 2: Creating a UIButton Image

Lets get started!

[Read more…]

5 Steps To Beginning App Development

Assumptions:

  1. You’re already familiar with Mac OS X and or iOS, if not I suggest following step 1 below and then familiarizing yourself with the Mac for a bit before continuing on to step 2.
  2. You are familiar with the concept of software and writing code, but haven’t necessarily written any before. If not check out Wikipedia for a quick crash course. http://en.wikipedia.org/wiki/Software & http://en.wikipedia.org/wiki/C_(programming_language) should do the trick!

Step 1: Buy a Mac & maybe an iOS device

If you want to develop apps for iOS (iPhone, iPad, etc.) or OS X (Mac) the first thing you will need is a Mac. While it is possible to develop apps for these platforms without a true Mac, I do not recommend going down this route, especially when just getting started.

I recommend getting a used MacBook Pro 2010 or newer off Craigslist or Ebay if you can’t muster up the cash for a new system! I started with a 21.5in iMac personally, but the portability of the laptop allows you to work away from the house and the coffee shop can be your best friend when writing software.

You will need to install the latest version of OS X (currently Mountain Lion) on the system, and I recommend ensuring it has a minimum of 4gb ram installed.

Step 2: Register for the Apple Developer Program

Registering for an Apple developer account is essential to beginning app development for iOS or OS X. It is very simple, just visit https://developer.apple.com and choose either iOS dev center or Mac Dev Center, then click register.

If you already have an iTunes account (Apple ID), you can link your developer account to that and avoid creating and remembering yet another password. There are a few different types of developer accounts and I won’t go into the details of each one, but you basically have two choices here:

  1. Free program – which allows you access to minimal resources and you can only run your apps on a device simulator
  2. Paid program – $100 per year which gives you access to an abundance of resources and the ability to install your apps on device

If you’re really serious about being an App Developer, I recommend biting the bullet and going for the paid program. In my opinion, not being able to see your creation running directly on your iPhone or iPad is a major disadvantage for a number of reasons. First of all, device testing is essential to developing an app that both looks great and performs well. Secondly, seeing an app that you developed running directly on your device is an awesome experience and one that can be the difference between giving up and carrying on (I would not let yourself pass on that experience if your serious about building apps). However, if you really can’t afford the $100 after throwing down some dough for that new Mac you purchased in step 1, then the free program will get you though the beginner process for awhile, but I would still recommend upgrading as soon as you can.

Another important feature of the paid program is the ability to download/view WWDC videos and sample code (World Wide Developer Conference). These are videos created by Apple engineers detailing the tools and APIs (Application Programming Interface) available from Apple. Many of these videos are of a “how to” format and are essential to developing great apps!

Once you have signed up for your developer account you can find the WWDC videos .and other resources here https://developer.apple.com/wwdc/

Step 3: Install Xcode

[Read more…]

css.php
Privacy Policy