weex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mos...@apache.org
Subject [incubator-weex] 01/01: [iOS] Convert to immutable instance. Make code stronger.
Date Thu, 01 Aug 2019 05:26:32 GMT
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 <qianyuan.wqy@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;


Mime
View raw message