Skip to content

Commit 3cbbee2

Browse files
committed
Merge pull request #38 from Vortec4800/master
Added subscripting support to FirebaseArray
2 parents 3544916 + a2dc4b0 commit 3cbbee2

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

FirebaseUI/Core/API/FirebaseArray.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,19 @@
102102
*/
103103
- (Firebase *)refForIndex:(NSUInteger)index;
104104

105+
/**
106+
* Support for subscripting. Resolves to objectAtIndex:
107+
* @param index The index of the item to retrieve
108+
* @return The object at the given index
109+
*/
110+
- (id)objectAtIndexedSubscript:(NSUInteger)idx;
111+
112+
/**
113+
* Support for subscripting. This method is unused and trying to write directly to the
114+
* array using subscripting will cause an assertion.
115+
*/
116+
- (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx;
117+
105118
#pragma mark -
106119
#pragma mark Private API methods
107120

FirebaseUI/Core/Implementation/FirebaseArray.m

100644100755
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,12 @@ - (Firebase *)refForIndex:(NSUInteger)index {
152152
return [(FDataSnapshot *)[self.snapshots objectAtIndex:index] ref];
153153
}
154154

155+
- (id)objectAtIndexedSubscript:(NSUInteger)index{
156+
return [self objectAtIndex:index];
157+
}
158+
159+
- (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)index{
160+
NSAssert(NO, @"Subscripting is read-only on FirebaseArray");
161+
}
162+
155163
@end

0 commit comments

Comments
 (0)