This project enables you to create and use strongly-typed collections in Objective-C projects.
Subclasses of the following collections are currently generated:
NSArrayNSMutableArray
The headers produced by this project can be found in a gist. You can clone them into your project with:
git clone git://gist.github.com/4187633.git NNStrongCollections
In files where you would like to use strongly-typed collections:
#import "NNStrongCollections.h"
NNStrongCollections(MYClass, thing, Thing, s)
The syntax is a bit odd, but it's hard to do better with macros. The arguments are:
MYClass: The class name of your type, likeNSObject(silly) orNSString.thing: The lower case singular name of an instance ofMYClass, like "string". It's a bad plan to use "object".Thing: The capitalized name of an instance ofMYClass, like "String". It's a bad plan to use "Object".s: The plural suffix for the names of instances ofMYClass.sprovides for "things" and "Things", but the name "gas" could use the plural suffixsesto produce "gasses" in the appropriate method names.
Somewhere in your project you should have an implementation file where these collections are defined. It should look similar to:
// Don't forget to define all the typed collections that you declare!
#import "NNStrongCollections+Implementation.h"
NNStrongCollections(MYClass, thing, Thing, s)
For more information, check out the example project. The collection implementations are generated in StrongCollections.m and are used in NNHello.m. Complete documentation can be found in the downloads section.
NNCollections is cobbled together using rake, which supports the following targets:
all: Build everything, and clean up the intermediate steps.build: Construct the interface and implementation headers.docs: Build the docset.lint: Sanity check to ensure that the source is syntactically correct and contains no obvious errors.test: Somewhat of a joke. Tests exist, and I use them, but I haven't checked in the harness yet because it's not ready.