Archive for the ‘Objective-C Programming’ Category

Easier Threading With NSOperation For Better Performance

Creating multi-threaded programs is one of the more complex issues for newer programmers.  When looking through the app store you can see many apps that freeze or jitter because the developers try to do everything in a single thread.

There is a Cocoa Touch class called NSOperation which makes this much simpler.

A new tutorial has been created called Turbo Charging Your Apps With NSOperation which illustrates some of the details of using the NSOperation classes and provides some iPhone sample code.

Save A UIImage Outside Of The Photo Album

In an earlier post I pointed out a tutorial on how to save pictures taken with the camera to a photo album.

John Muchow has written a new tutorial this time showing how to save PNG or JPG images to the documents directory.

This is done by using the UIImageJPEGRepresentation or UIImagePNGRepresentation functions to save the images, and writing to the documents directory.

The full code snippet can be found here: Save UIImage Object As A PNG or JPEG File

iPhone XML Parser Performance Guide

Parsing XML on the iPhone is a somewhat tedious task because the NSXMLDocument class available on the Mac is not available on the iPhone.  Fortunately, there are several different iphone XML parsing libraries now available on the iPhone.

There is wide variation in the performance of these XML parsers, fortunately Ray Wenderlich has written an excellent guide comparing the efficiency of these libraries in both time and memory space.

UITextField Validation That Also Handles Copy/Paste

A nifty little code snippet has been posted by John Muchow.

What it does, by simply dropping in the given snippet into the delegate for the text field, is apply simple validation using an NSCharacterSet in which you define the unacceptable characters, and apply that on a string using the componentsSeparatedByCharactersInSet. A very nice and quick way for doing simple validation, and it will validate characters that you try pasting in the UITextField from the clipboard.

2 Approaches To Twitpic Integration

I recently came across a couple of different tutorials on integrating TwitPic into your iPhone apps.

The first tutorial takes the approach of using the ASIHttpRequest library which allows for easier communication with web applications, and the second goes through each step using only Cocoa libraries for those that are looking for those who want to learn how it’s done using Apple’s URL loading system.

The first tutorial can be found here and the second can be found here.