Nobody should forget Objective-C offers a pretty nice variant: Objective-C++. And the C++ standard library provides the data structures you need, well tested, debugged, stable, and as fast as possible. Best, they'll work with ARC perfectly. Bestest, you can even choose between __weak
or __strong
pointers if you feels it.
Have a look at <queue>
and <stack>
.
That said, NSMutableArray
works perfectly well for stacks: -addObject:
, -lastObject
and -removeLastObject
will do the job nicely with good performance.
C++ can be verbose. Horribly verbose. But it also have some elegance here and there, and some very powerful constructs. Some parts of the standard library truly shine, and the data structures are among the pearls once the alien syntax is mastered. It can be hidden with a few typedefs anyway.