Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

当 Str 是空的时候会崩溃 #8

Open
rpplusplus opened this issue Sep 22, 2015 · 0 comments
Open

当 Str 是空的时候会崩溃 #8

rpplusplus opened this issue Sep 22, 2015 · 0 comments

Comments

@rpplusplus
Copy link
Contributor

有这么一个问题,当 Str 从服务器拿到的时候,有可能是空的。这个时候 Typeset 会崩。例如:

    NSString* str = nil;
    TypesetKit* result = str.typeset;
    result.color([UIColor redColor]);

    NSLog(@"%@", result);

可以看到这里是有问题的,最后一行 callq

    0x10feeb45d <+141>: movq   -0x30(%rbp), %rdi
    0x10feeb461 <+145>: movq   %rax, %rsi
    0x10feeb464 <+148>: movq   -0x40(%rbp), %rcx
    0x10feeb468 <+152>: movq   %rax, -0x48(%rbp)
    0x10feeb46c <+156>: callq  *0x10(%rcx)

我想了一下貌似没法避免,但是可以用其他的方式绕过去...

例如写一个:

#define TypesetBuilder(__STR__) (__STR__==nil?@"".typeset:__STR__.typeset)

你觉得呢?(^~^;)ゞ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant