美文网首页
NSString一些知识

NSString一些知识

作者: bigCatloveFish | 来源:发表于2018-08-26 19:00 被阅读8次
        NSString *str = @"123";
        NSString *str2 = [NSString stringWithFormat:@"123"];
    

    这两种声明方式有什么区别?将上面代码 clang -rewrite-objc 变成c++代码。

    NSString *str = (NSString *)&__NSConstantStringImpl__var_folders_k8_nvb1mj_10hz6hjz_j35dr4gw0000gn_T_main_52b509_mi_0;
    NSString *str2 = ((NSString * _Nonnull (*)(id, SEL, NSString * _Nonnull, ...))(void *)objc_msgSend)((id)objc_getClass("NSString"), sel_registerName("stringWithFormat:"), (NSString *)&__NSConstantStringImpl__var_folders_k8_nvb1mj_10hz6hjz_j35dr4gw0000gn_T_main_52b509_mi_1);
    
    static __NSConstantStringImpl __NSConstantStringImpl__var_folders_k8_nvb1mj_10hz6hjz_j35dr4gw0000gn_T_main_52b509_mi_0 __attribute__ ((section ("__DATA, __cfstring"))) = {__CFConstantStringClassReference,0x000007c8,"123",3};
    static __NSConstantStringImpl __NSConstantStringImpl__var_folders_k8_nvb1mj_10hz6hjz_j35dr4gw0000gn_T_main_52b509_mi_1 __attribute__ ((section ("__DATA, __cfstring"))) = {__CFConstantStringClassReference,0x000007c8,"123",3};
    

    (section ("__DATA, __cfstring")在可执行文件中


    ios可执行文件图.jpg

    相关文章

      网友评论

          本文标题:NSString一些知识

          本文链接:https://www.haomeiwen.com/subject/nobbiftx.html