English 中文(简体)
Non-i± Use of UIDocument
原标题:Non-iCloud use of UIDocument

I m trying to use UIDocument without iCloud when the user has iCloud disabled. I have the following code:

NSURL *url;
if (_isiCloudEnabled) {
    NSURL *ubiq = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
    url = [ubiq URLByAppendingPathComponent:[NSString stringWithFormat:@"%f.adoc",[[NSDate date] timeIntervalSince1970]]];
} else {
    NSString *homeDirectoryPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    NSString *newFilePath = [homeDirectoryPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%f.adoc", [[NSDate date] timeIntervalSince1970]]];
    url = [NSURL URLWithString:newFilePath];
}

ASListyDocument *d = [[ASListyDocument alloc] initWithFileURL:url];

该法典给我留下了错误:

*** Terminating app due to uncaught exception  NSInvalidArgumentException , reason:  must pass a valid file URL to -[UIDocument initWithFileURL:] 

是什么想法呢?” 我认为,LL是 de弄的,似乎是正确的。 我还尝试在模拟和打电话上播放。

顺便说一句,Im在一台带有5号的装置上运行,如果是这样的话。

最佳回答

这很可能使URL你重新建设起来。

NSString *homeDirectoryPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *newFilePath = [homeDirectoryPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%f.adoc", [[NSDate date] timeIntervalSince1970]]];
url = [NSURL URLWithString:newFilePath];

确实,这只是一条路。 Don t 忘记,有效的URL需要一种计划;对于档案来说,这是“档案资料”。 Try building the file URL using [NSURL fileURLWith Path:]

url = [NSURL fileURLWithPath:newFilePath];
问题回答

暂无回答




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签