iOS Programming Recipe 26: Using Collection Operators

Assumptions

  • 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.

[Read more…]

iOS Programming Recipe 25: Implementing Blocks Part I

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.

[Read more…]

iOS Programming Recipe 24: Creating a Mask for Clipping Drawings

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.

[Read more…]

5 Time Saving Tips In Xcode

Working with Xcode can sometimes be a frustrating experience…

However, Xcode has a few times saving features that really make a difference in day to day development. In this post we are going to break from the traditional format in order to examine a few of these features.

1. Snippets

Xcode snippets have gotten a bad wrap since they were introduced. This is mostly because they seem to lack some obvious features and are poorly documented. However, this doesn’t stop them from being an immensely powerful addition to Xcode. So let’s dive into using existing snippets and creating new ones.

[Read more…]

iOS Programming Recipe 20: Using CAGradientLayer In A Custom View

This recipe will demonstrate how to use CAGradientLayer to add gradients to a custom UIView.

Assumptions

  • You should have basic knowledge of UIView and Core Animation, specifically CALayer.
  • Basic knowledge of autolayout usage in interface builder.

Getting Started

Setting Up A Sample Application
  • Create a new Single View Application in Xcode named GradientViewDemo. Make sure to check Use Automatic Reference Counting and uncheck Use Storyboards. Our demo app will also be iPhone only to keep things simple, but go ahead make a universal app if you like (everything we will do is applicable on both iPhone and iPad),
  • Create a new UIView subclass named NSCBGradientView. We added the NSCB class prefix, because this may be a valuable component to reuse in future projects and the prefix will help avoid name clashing.
  • Next, we need to add QuartzCore to the target. Do so by selecting the project file in the source list on the left, then ensure the GradientViewDemo target has been selected, select the Build Phases tab from the tab bar at the top, expand the Link Binary with Libraries, and finally click the + button in the lower left corner. Search for QuartzCore, and then add it to the target.

[Read more…]

iOS Programming Recipe 10: Adding A Shadow To UIView

Assumptions

Shadows!

Even the slightest drop shadow here and there can dramatically improve the look of your application’s UI, but at what cost?

Today we will cover adding shadows to UIViews of all kinds. Feel free to check out the source code for this recipe available on our GitHub page.

[Read more…]

iOS Programming Recipe 8: Using UIAppearance For A Custom Look

Everyone wants to make their app look unique! Well the UIAppearance protocol can help you! In iOS 5.0 Apple introduced the UIAppearance proxy API which allows you the developer to customize many of the appearance aspects of UIKit elements. I know what you’re thinking… Can’t I already do that? Well sure, but not on the same scale as UIAppearance will allow, and furthermore, changing the appearance of UI components on a per object basis gets really old, really fast.

So let’s dive into an example right quick…

Say you have an app with a UINavigationBar and you want something other than the default background color (tint color). You would probably try something similar to the following


[self.navigationBar setTintColor:myColor];

Then you decide another part of your app needs a navigation bar and you end up writing the same code to change the background color for that one as well. This continues as time goes on and before long you end up with an unmanageable mess, leaving you sad and depressed wishing there was a better way… enter UIAppearance…

[Read more…]

iOS Programming Recipe 6: Creating a custom UIView using a Nib

Creating a custom UIView using a Nib

Assumptions
  1. You are familiar with creating UIView subclasses, and instantiating UIView’s both from a Nib file or in code
  2. You are familiar with Nib files
Background

Sometimes you find yourself trying to create a quick composite UIView (UIView subclass w/ multiple subviews) where a UIViewController doesn’t seem necessary Please note that a UIViewController is the right choice most of the time. This can be a real pain to setup entirely in code if you have many subviews, and god forbid if you want to use auto layout! So you may find yourself wanting to use a nib to simplify things a bit, well this tutorial will go through the process of doing just that.

Getting Started
  • Create a new Xcode project based on the single view application template for iOS. This tutorial will assume you are using ARC, so you may want to make that selection when creating the new project.
  • Once you have created the new project a new UIView subclass to the project and name it CustomView.
  • Then create a new Nib file named CustomView.nib and add it to the project.
[Read more…]

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…]

css.php
Privacy Policy