2014-01-13 51 views
0

我不斷收到上述警告消息與此代碼行,但無法弄清楚如何糾正它。數據參數未使用格式字符串在錯誤消息

*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]]; 

回答

1

錯誤是一個錯字:「& @」而不是「%@」。

考慮編寫代碼更是這樣的:

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]; 

有了這個代碼的格式錯誤將本身一直在一條線,很容易找到。

編寫供人閱讀的代碼,而不是編譯器。

+0

不敢相信我沒有看到。這是在我沒有寫的代碼的ASIHTTPRequest庫中,所以我沒有完成格式化。 – user717452

相關問題