Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 10-07-2009, 07:54 PM   #3 (permalink)
SamRhoads
Registered Member
 
Join Date: Jun 2009
Posts: 10
SamRhoads is on a distinguished road
Default

Sure, I know that.

Quote:
Originally Posted by smasher View Post
NSMutableArray has an "addObject:" method, which is equivalent to push, and "removeLastObject:" which you could combine with the "lastObject:" method it inherits from NSArray.

You could subclass from NSMutableArray and just add the methods you need; the only reason not to subclass would be to restrict access to the default methods of NSArray and NSMutableArray. But then you'll have to write your own copy methods, etc.

You could also use a "category" to add your custom methods to NSMutableArray without creating a new class, but that might be a bit confusing if you haven't studied it before. Categories let you add methods (but not variables) to existing classes, even system classes.

That'll give you two pointers to the same stack. You'll want to use [stackA copy] instead if you need a separate stack.
I did not try using categories. Maybe that would have done what I wanted.

And I do want two references to the same stack.

Anyway, I finally did create a new class that is NOT a subclass of NSMutableArray, and it behaves JUST like a Stack should. I'll post the code if anyone is interested.

Sam.
SamRhoads is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,282
Threads: 93,959
Posts: 402,319
Top Poster: BrianSlick (7,971)
Welcome to our newest member, kurtwatson
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:03 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.