You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by mo...@apache.org on 2019/08/01 05:26:32 UTC
[incubator-weex] 01/01: [iOS] Convert to immutable instance. Make
code stronger.
This is an automated email from the ASF dual-hosted git repository.
moshen pushed a commit to branch protect-argument-immutable-conversion
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git
commit fdf1a316830bba7e8649ff5d0abb65a28f9ee62a
Author: qianyuan.wqy <qi...@taobao.com>
AuthorDate: Thu Aug 1 13:26:18 2019 +0800
[iOS] Convert to immutable instance. Make code stronger.
---
ios/sdk/WeexSDK/Sources/Utility/WXUtility.m | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
index bbc42e0..55db3c1 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
@@ -270,14 +270,16 @@ CGFloat WXFloorPixelValue(CGFloat value)
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;