* [ios] parse fetch response while the callback is existed
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/343ad6f1 Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/343ad6f1 Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/343ad6f1 Branch: refs/heads/master Commit: 343ad6f1b49bab8908f298a25f25ca9eb4f8ba06 Parents: 0e1470a Author: acton393 <zhangxing610...@gmail.com> Authored: Wed Oct 18 11:04:28 2017 +0800 Committer: acton393 <zhangxing610...@gmail.com> Committed: Wed Oct 18 11:04:28 2017 +0800 ---------------------------------------------------------------------- ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/343ad6f1/ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m ---------------------------------------------------------------------- diff --git a/ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m b/ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m index 4b01cde..bd96806 100644 --- a/ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m +++ b/ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m @@ -85,20 +85,16 @@ WX_EXPORT_METHOD(@selector(fetchWithArrayBuffer:options:callback:progressCallbac }; loader.onFinished = ^(const WXResourceResponse * response, NSData *data) { - if (weakSelf) { - [weakSelf _loadFinishWithResponse:[response copy] data:data callbackRsp:callbackRsp]; - if (callback) { - callback(callbackRsp); - } + if (weakSelf && callback) { + [weakSelf _loadFinishWithResponse:[response copy] data:data callbackRsp:callbackRsp]; + callback(callbackRsp); } }; loader.onFailed = ^(NSError *error) { - if (weakSelf) { + if (weakSelf && callback) { [weakSelf _loadFailedWithError:error callbackRsp:callbackRsp]; - if (callback) { - callback(callbackRsp); - } + callback(callbackRsp); } }; @@ -268,7 +264,7 @@ WX_EXPORT_METHOD(@selector(fetchWithArrayBuffer:options:callback:progressCallbac NSError * error = nil; id jsonObj = [WXUtility JSONObject:data error:&error]; if (error) { - WXLogError(@"%@", [error description]); + WXLogDebug(@"%@", [error description]); } return jsonObj; }