Skip to content

Instantly share code, notes, and snippets.

@thechrisoshow
Created September 21, 2012 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thechrisoshow/3761843 to your computer and use it in GitHub Desktop.
Save thechrisoshow/3761843 to your computer and use it in GitHub Desktop.
@interface BananaBox : NSObject
- (id)objectAtIndexedSubscript:(NSUInteger)idx;
- (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx;
@end
@implementation AppleCart
NSMutableArray *_bananas;
-(id) init {
self = [self init]
if (self} {
_bananas = [[NSMutableArray alloc] init];
}
return self;
}
- (id)objectAtIndexedSubscript:(NSUInteger)idx {
return _bananas[idx];
}
- (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx {
_bananas[idx] = obj;
}
@end
BananaBox *bananaBox = [[BananaBox alloc] init];
bananaBox[0] = @"Delicious banana";
bananBox[0]; // Returns "Delicious banana"
@xhruso00
Copy link

instead of @implementation AppleCart should be @implementation BananaBox, right?
+
There is typo in bananBox[0];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment