A-Star (A*) is a pathfinding algorithm commonly used in games and artificial intelligence systems. It can be tricky to implement, however, and despite its ubiquitous nature when I was first attempting to implement it years ago I was unable to find any straightforward examples in Objective-C (or C) on the net.

The following Objective-C code and demo project demonstrate how to implement A* in your iPhone or Mac apps using common foundation classes (such as NSArray).

This code is a little old and could use some improvement, but hopefully it will provide a helpful starting point for anyone looking to implement pathfinding in their iPhone games or Mac apps.

Github Project

Download the Xcode Project

The code

Visual demo of the Xcode project: