Guest User

Untitled

a guest
Jun 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #import <Foundation/Foundation.h>
  2.  
  3. @interface StackClass<T:id<CustomAddProtocol>> : NSObject
  4. @property (nonatomic,retain) NSMutableArray *items;
  5. - (void)push:(T)value;
  6. - (T)pop;
  7. @end
  8.  
  9.  
  10. #import "StackClass.h"
  11.  
  12. @implementation StackClass
  13. - (instancetype)init {
  14. self = [super init];
  15. self.items = [[NSMutableArray alloc]init];
  16. return self;
  17. }
  18.  
  19. - (void)push:(id)value {
  20. [self.items addObject:value];
  21. }
  22.  
  23. - (id)pop {
  24. id last = [self.items lastObject];
  25. [self.items removeLastObject];
  26. return last;
  27. }
  28.  
  29. @end
Add Comment
Please, Sign In to add comment