Skip to content

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

@rpplusplus

Description

@rpplusplus

有这么一个问题,当 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)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions