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)
答案 0 :(得分:1)
您似乎没有附加format
,而是附加string
,这可能是编译器抱怨的原因。尝试使用stringByAppendingString
,如此
NSString *file = [documentDirectory stringByAppendingString:[NSString stringWithFormat:@"/%@.pdf", _idNo]];
它应该有效。或者,如果您真的想使用stringByAppendingFormat
,请执行以下操作:
NSString *file = [documentDirectory stringByAppendingFormat:@"/%@.pdf", _idNo];