ios - NSString 中的对象太多? %@.%@.%@ 产生格式错误

标签 ios objective-c

   NSLog(@"here is date string %@", dateString);
   NSLog(@"here is file name %@", [NSString stringWithFormat: @"%@.%@.%@.%d.MOV", self.latitude, self.longitude, dateString, rand_int ]);

结果

2015-08-28 13:57:55.378 video[709:261408] here is date string 2015-08-28
2015-08-28 13:57:55.379 video[709:261408] here is file name 40.747062.-73.915204.@.363582320.MOV

似乎连续的 3 个 %@'s 应该是 lat、lon 和 dateString,但最后一个 .%@. 似乎在打印输出时变成了普通的旧 @ 。我错过了什么?

最佳答案

您的格式字符串中的第三个 % 和 @ 之间有一个 gremlin(控制字符)。您可以通过将插入点放在 @ 后面并退格两次,然后重新键入 @ 来修复它。

如果您在进行我描述的更改之前在 TextMate 中打开文件,您将看到额外的字符:

Control character

(OS X 的编译器会针对此 gremlin 显示警告,但它并不是很有帮助。)

关于ios - NSString 中的对象太多? %@.%@.%@ 产生格式错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32277205/

相关文章:

iphone - 我们如何实现像 "pull to reload"选项这样的 Facebook 应用程序?

ios - 从 nsurlconnection 委托(delegate)方法返回响应数据

ios - 如何为 iOS 构建 DLIB

android - 增强现实 Vuforia- 什么是标记

iphone 网络服务应用程序

iphone - 我如何在方法中使用此值 - Objective C

iphone - 我如何通过编程禁用 TableView Cell 点击?

ios - 在 iOS 中重新创建商店

ios - iOS 上的面部表情识别

ios - AVPlayer 不同步