Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[iOS] Convert to immutable instance. Make code stronger. (#2772)
Browse files Browse the repository at this point in the history
  • Loading branch information
wqyfavor authored and jianhan-he committed Aug 1, 2019
1 parent 10ddece commit dc63c56
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
Expand Up @@ -270,14 +270,16 @@ + (id _Nullable)convertContainerToImmutable:(id _Nullable)source
for (id obj in source) {
[tmpArray addObject:[self convertContainerToImmutable:obj]];
}
return [NSArray arrayWithArray:tmpArray];
id immutableArray = [NSArray arrayWithArray:tmpArray];
return immutableArray ? immutableArray : tmpArray;
}
else if ([source isKindOfClass:[NSDictionary class]]) {
NSMutableDictionary* tmpDictionary = [[NSMutableDictionary alloc] init];
for (id key in [source keyEnumerator]) {
tmpDictionary[key] = [self convertContainerToImmutable:[source objectForKey:key]];
}
return [NSDictionary dictionaryWithDictionary:tmpDictionary];
id immutableDict = [NSDictionary dictionaryWithDictionary:tmpDictionary];
return immutableDict ? immutableDict : tmpDictionary;
}

return source;
Expand Down

0 comments on commit dc63c56

Please sign in to comment.