gpt4 book ai didi

ios - 错误消息中的格式字符串未使用数据参数

转载 作者:行者123 更新时间:2023-11-29 03:20:59 24 4
gpt4 key购买 nike

我在这行代码中不断收到上述警告消息,但不知道如何更正它。

    *err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:
[NSString stringWithFormat:@"Decompression of %@ failed because we were unable to write to the destination data file at &@",sourcePath,destinationPath],
NSLocalizedDescriptionKey,
[outputStream streamError],
NSUnderlyingErrorKey,
nil]];

最佳答案

错误是拼写错误:“&@”而不是“%@”。

考虑像这样编写代码:

NSString *messageText = [NSString stringWithFormat:@"Decompression of %@ failed because we were unable to write to the destination data file at %@", sourcePath, destinationPath];
NSString *streamErrorText = [outputStream streamError];
NSDictionary *userInfo = @{NSLocalizedDescriptionKey : messageText,
NSUnderlyingErrorKey : streamErrorText};
NSError *err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:userInfo];

使用这种代码格式,错误会单独出现在一行中并且很容易找到。

编写代码供人们阅读,而不是编译器。

关于ios - 错误消息中的格式字符串未使用数据参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21096124/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com