Skip to content

Instantly share code, notes, and snippets.

@woolsweater
Last active August 29, 2015 14:05
Show Gist options
  • Save woolsweater/38ad03759e6245bf6733 to your computer and use it in GitHub Desktop.
Save woolsweater/38ad03759e6245bf6733 to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
@interface ArrayReturner : NSObject
@property (copy, nonatomic) NSArray * array;
@end
@implementation ArrayReturner
{
NSMutableArray * _array;
}
- (BOOL)myArrayIsIdenticalTo:(NSArray *)otherArray
{
return _array == otherArray;
}
@end
int main(int argc, const char *argv[])
{
@autoreleasepool {
ArrayReturner * a = [ArrayReturner new];
[a setArray:@[@1, @2]];
NSArray * returnedArray = [a array];
// Does not throw
NSCAssert([a myArrayIsIdenticalTo:returnedArray],
@"Returned array is a separate instance.");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment