Last active
December 12, 2015 09:48
-
-
Save leafduo/4753917 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // main.m | |
| // Foo | |
| // | |
| // Created by leafduo on 2/11/13. | |
| // Copyright (c) 2013 leafduo.com. All rights reserved. | |
| // | |
| #import <Foundation/Foundation.h> | |
| #import "NSMutableArray+Pop.h" | |
| int main(int argc, const char * argv[]) | |
| { | |
| @autoreleasepool { | |
| NSMutableArray *array = [@[@1, @2, @3] mutableCopy]; | |
| NSLog(@"%@", [array pop]); | |
| NSLog(@"%@", array); | |
| } | |
| return 0; | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // NSMutableArray+Pop.h | |
| // Foo | |
| // | |
| // Created by leafduo on 2/11/13. | |
| // Copyright (c) 2013 leafduo.com. All rights reserved. | |
| // | |
| #import <Foundation/Foundation.h> | |
| @interface NSMutableArray (Pop) | |
| - (id)pop; | |
| @end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // NSMutableArray+Pop.m | |
| // Foo | |
| // | |
| // Created by leafduo on 2/11/13. | |
| // Copyright (c) 2013 leafduo.com. All rights reserved. | |
| // | |
| #import "NSMutableArray+Pop.h" | |
| @implementation NSMutableArray (Pop) | |
| - (id)pop { | |
| id obj = [self.lastObject copy]; | |
| [self removeObject:self.lastObject]; | |
| return obj; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment