Tom*_*ulc 2 cocoa-touch objective-c nsmutablestring
为什么我的NSMutableString潜在不安全?我搜索了这个但找不到任何东西.
int hour = [number intValue] / 3600;
NSMutableString *time = [[NSMutableString alloc] initWithString:@""];
if (hour < 9) {
[time appendFormat:@"0"];
[time appendFormat:[NSMutableString stringWithFormat:@"%d:", hour]];
}
Run Code Online (Sandbox Code Playgroud)
它出什么问题了?这是我第一次看到这个.
woz*_*woz 10
改变这个:
[time appendFormat:[NSMutableString stringWithFormat:@"%d:", hour]];
Run Code Online (Sandbox Code Playgroud)
对此:
[time appendFormat:@"%d:", hour];
Run Code Online (Sandbox Code Playgroud)
该appendFormat方法需要你传递一个字符串格式,而不是一个NSMutableString.此屏幕截图显示:

| 归档时间: |
|
| 查看次数: |
441 次 |
| 最近记录: |