diff options
author | Ibrahim Ulukaya <ulukaya@gmail.com> | 2017-11-08 17:22:01 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-08 17:22:01 -0500 |
commit | 07595ce66bbd90be37940facd8601b3d94eec837 (patch) | |
tree | fa0c15255e6f7b33a7bce6bf69819d64639a4a1f | |
parent | d400851b29823273036df136eabd815d6ba0d1cf (diff) |
Enumerator using generic. Cleaner for .. in .. loop in Swift (#433)
* Enumerator using generic. Cleaner for .. in .. loop in Swift
So
for childSnapshot in snapshot.children {
you don't need to cast each child. Each cild is already known as DataSnapshot
* Update FIRDataSnapshot.h
* Update FIRMutableData.h
* Update FIRMutableData.m
-rw-r--r-- | Firebase/Database/Api/FIRDataSnapshot.m | 2 | ||||
-rw-r--r-- | Firebase/Database/Api/FIRMutableData.m | 2 | ||||
-rw-r--r-- | Firebase/Database/Public/FIRDataSnapshot.h | 2 | ||||
-rw-r--r-- | Firebase/Database/Public/FIRMutableData.h | 2 |
4 files changed, 4 insertions, 4 deletions
diff --git a/Firebase/Database/Api/FIRDataSnapshot.m b/Firebase/Database/Api/FIRDataSnapshot.m index 9559c38..b774493 100644 --- a/Firebase/Database/Api/FIRDataSnapshot.m +++ b/Firebase/Database/Api/FIRDataSnapshot.m @@ -87,7 +87,7 @@ return [self.node.node numChildren]; } -- (NSEnumerator *) children { +- (NSEnumerator<FIRDataSnapshot *> *) children { return [[FTransformedEnumerator alloc] initWithEnumerator:self.node.childEnumerator andTransform:^id(FNamedNode *node) { FIRDatabaseReference *childRef = [self.ref child:node.name]; return [[FIRDataSnapshot alloc] initWithRef:childRef indexedNode:[FIndexedNode indexedNodeWithNode:node.node]]; diff --git a/Firebase/Database/Api/FIRMutableData.m b/Firebase/Database/Api/FIRMutableData.m index 7e10dcd..77a022a 100644 --- a/Firebase/Database/Api/FIRMutableData.m +++ b/Firebase/Database/Api/FIRMutableData.m @@ -110,7 +110,7 @@ return [self.data getNode:self.prefixPath]; } -- (NSEnumerator *) children { +- (NSEnumerator<FIRMutableData *> *) children { FIndexedNode *indexedNode = [FIndexedNode indexedNodeWithNode:self.nodeValue]; return [[FTransformedEnumerator alloc] initWithEnumerator:[indexedNode childEnumerator] andTransform:^id(FNamedNode *node) { FPath* childPath = [self.prefixPath childFromString:node.name]; diff --git a/Firebase/Database/Public/FIRDataSnapshot.h b/Firebase/Database/Public/FIRDataSnapshot.h index c3082df..e465045 100644 --- a/Firebase/Database/Public/FIRDataSnapshot.h +++ b/Firebase/Database/Public/FIRDataSnapshot.h @@ -134,7 +134,7 @@ FIR_SWIFT_NAME(DataSnapshot) * * @return An NSEnumerator of the children. */ -@property (strong, readonly, nonatomic) NSEnumerator* children; +@property (strong, readonly, nonatomic) NSEnumerator<FIRDataSnapshot *>* children; /** * The priority of the data in this FIRDataSnapshot. diff --git a/Firebase/Database/Public/FIRMutableData.h b/Firebase/Database/Public/FIRMutableData.h index 5c26024..4e7250a 100644 --- a/Firebase/Database/Public/FIRMutableData.h +++ b/Firebase/Database/Public/FIRMutableData.h @@ -116,7 +116,7 @@ FIR_SWIFT_NAME(MutableData) * Note that this enumerator operates on an immutable copy of the child list. So, you can modify the instance * during iteration, but the new additions will not be visible until you get a new enumerator. */ -@property (readonly, nonatomic, strong) NSEnumerator* children; +@property (readonly, nonatomic, strong) NSEnumerator<FIRMutableData *>* children; /** |