format string is not a string literal(以前的解决方案没有帮助)
format string is not a string literal (previous solutions does not help)
NSData *pdfURL = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",_paperURL]]];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [paths objectAtIndex:0];
//line with error
NSString *file = [documentDirectory stringByAppendingFormat:[NSString stringWithFormat:@"/%@.pdf", _idNo]];
//ive also tried adding nil at the end
NSString *file = [documentDirectory stringByAppendingFormat:[NSString stringWithFormat:@"/%@.pdf", _idNo, nil]];
下面列出了一些我试过但没有帮助的答案。任何帮助将不胜感激
Warning : Format string is not a string literal (potentially insecure)
Issue With Code: Format string is not a string literal
您似乎没有附加 format
,而是附加了 string
,这可能就是编译器抱怨的原因。尝试像这样使用 stringByAppendingString
NSString *file = [documentDirectory stringByAppendingString:[NSString stringWithFormat:@"/%@.pdf", _idNo]];
它应该可以工作。或者,如果您真的想使用 stringByAppendingFormat
,请这样做:
NSString *file = [documentDirectory stringByAppendingFormat:@"/%@.pdf", _idNo];
NSData *pdfURL = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",_paperURL]]];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [paths objectAtIndex:0];
//line with error
NSString *file = [documentDirectory stringByAppendingFormat:[NSString stringWithFormat:@"/%@.pdf", _idNo]];
//ive also tried adding nil at the end
NSString *file = [documentDirectory stringByAppendingFormat:[NSString stringWithFormat:@"/%@.pdf", _idNo, nil]];
下面列出了一些我试过但没有帮助的答案。任何帮助将不胜感激
Warning : Format string is not a string literal (potentially insecure)
Issue With Code: Format string is not a string literal
您似乎没有附加 format
,而是附加了 string
,这可能就是编译器抱怨的原因。尝试像这样使用 stringByAppendingString
NSString *file = [documentDirectory stringByAppendingString:[NSString stringWithFormat:@"/%@.pdf", _idNo]];
它应该可以工作。或者,如果您真的想使用 stringByAppendingFormat
,请这样做:
NSString *file = [documentDirectory stringByAppendingFormat:@"/%@.pdf", _idNo];