【问题标题】:What do %@ and %ld mean in Objective-C? [duplicate]Objective-C 中的 %@ 和 %ld 是什么意思? [复制]
【发布时间】:2015-07-30 18:19:17
【问题描述】:

NSString *expectedURL = [NSString stringWithFormat:@"https://%@:%ld/%@"];

%@%ld 是什么意思?

【问题讨论】:

标签: objective-c string cocoa cocoa-touch nsstring


【解决方案1】:

%@ 用于打印和格式化 Objective-c 对象的格式说明符。

%ld 用于无符号 64 位整数。即NSInteger。

【讨论】:

  • Is 不仅适用于基础对象,还适用于所有对象。
【解决方案2】:

它们是格式说明符。基本上,其余参数的插入点到stringWithFormat

https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-12
    • 1970-01-01
    • 1970-01-01
    • 2014-01-31
    • 2013-09-02
    相关资源
    最近更新 更多