Tôi cố gắng lấy đường dẫn tệp của tệp có tên "temp.pdf" nằm trong thư mục NSTemporaryDirectory (tôi đã kiểm tra, tệp tồn tại).Nhận đường dẫn tệp và URL cho tệp trong thư mục tạm thời
tôi sử dụng này:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"temp" ofType:@"pdf" inDirectory:NSTemporaryDirectory()];
Tôi đã thử với:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"temp.pdf" ofType:@"" inDirectory:NSTemporaryDirectory()];
Và:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"temp" ofType:@"pdf"];
Nhưng có vẻ như nó không hoạt động, giá trị trả về là luôn luôn rỗng.
Vì vậy, tôi hơi bối rối, ai đó có thể giúp tôi?
Cảm ơn bạn.
OK, khi tôi làm điều đó, tôi muốn sử dụng filepath với [tương tác UIDocumentInteractionControllerControllerWithURL: filepath]; Tôi đã tạo [url url của NSURLWithString: filepath], nhưng Xcode nói: "Lược đồ không hợp lệ (null). Chỉ hỗ trợ lược đồ tệp." – HasgardLucian
Thử 'NSURL * furl = [NSURL fileURLWithPath: [NSTemporaryDirectory() stringByAppendingPathComponent: @" temp.pdf "]];' – Joe
Điều gì xảy ra nếu chúng ta muốn trả về tất cả các tệp pdf trong thư mục tạm thời? –