Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import <Foundation/Foundation.h>
- @interface StackClass<T:id<CustomAddProtocol>> : NSObject
- @property (nonatomic,retain) NSMutableArray *items;
- - (void)push:(T)value;
- - (T)pop;
- @end
- #import "StackClass.h"
- @implementation StackClass
- - (instancetype)init {
- self = [super init];
- self.items = [[NSMutableArray alloc]init];
- return self;
- }
- - (void)push:(id)value {
- [self.items addObject:value];
- }
- - (id)pop {
- id last = [self.items lastObject];
- [self.items removeLastObject];
- return last;
- }
- @end
Add Comment
Please, Sign In to add comment