* [ios] try to fix text init crash
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/9fe39ad7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/9fe39ad7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/9fe39ad7 Branch: refs/heads/0.16-dev Commit: 9fe39ad707e6c433cb5ce40e8c2126c2d5a1faac Parents: 3073616 Author: acton393 <zhangxing610...@gmail.com> Authored: Mon Sep 25 15:29:08 2017 +0800 Committer: acton393 <zhangxing610...@gmail.com> Committed: Mon Sep 25 15:29:08 2017 +0800 ---------------------------------------------------------------------- ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/9fe39ad7/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m ---------------------------------------------------------------------- diff --git a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m index 7556074..4653089 100644 --- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m +++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m @@ -389,8 +389,12 @@ do {\ - (NSMutableAttributedString *)buildCTAttributeString { - NSString *string = [NSString stringWithFormat:@"%@", [self text] ?: @""]; - NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string]; + NSString * string = [self text]; + if (![string isKindOfClass:[NSString class]]) { + WXLogError(@"text %@ is invalid", [self text]); + string = @""; + } + NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString: string]; if (_color) { [attributedString addAttribute:NSForegroundColorAttributeName value:_color range:NSMakeRange(0, string.length)]; }