1 Star 0 Fork 0

yangxw8820 / XcodeOCSnippets

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
oc_document_delete.codesnippet 1.89 KB
一键复制 编辑 原始数据 按行查看 历史
yangxw 提交于 2018-10-16 11:31 . init
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDECodeSnippetCompletionPrefix</key>
<string>document_delete</string>
<key>IDECodeSnippetCompletionScopes</key>
<array>
<string>ClassImplementation</string>
</array>
<key>IDECodeSnippetContents</key>
<string>- (void)deleteDocument:(UIDocument *)document withCompletionBlock:(void (^)())completionBlock {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
NSError *fileCoordinatorError = nil;
[[[NSFileCoordinator alloc] initWithFilePresenter:nil] coordinateWritingItemAtURL:document.fileURL options:NSFileCoordinatorWritingForDeleting error:&amp;fileCoordinatorError byAccessor:^(NSURL *newURL) {
// extra check to ensure coordinator is not running on main thread
NSAssert(![NSThread isMainThread], @"Must be not be on main thread");
// create a fresh instance of NSFileManager since it is not thread-safe
NSFileManager *fileManager = [[NSFileManager alloc] init];
NSError *error = nil;
if (![fileManager removeItemAtURL:newURL error:&amp;error]) {
NSLog(@"Error: %@", error);
// TODO handle the error
}
if (completionBlock) {
completionBlock();
}
}];
});
}</string>
<key>IDECodeSnippetIdentifier</key>
<string>67823B27-1A69-4AB1-B341-7830FBA0FD62</string>
<key>IDECodeSnippetLanguage</key>
<string>Xcode.SourceCodeLanguage.Objective-C</string>
<key>IDECodeSnippetSummary</key>
<string>Delete Document</string>
<key>IDECodeSnippetTitle</key>
<string>Delete Document</string>
<key>IDECodeSnippetUserSnippet</key>
<true/>
<key>IDECodeSnippetVersion</key>
<integer>2</integer>
</dict>
</plist>
1
https://gitee.com/yangxw8820/XcodeOCSnippets.git
git@gitee.com:yangxw8820/XcodeOCSnippets.git
yangxw8820
XcodeOCSnippets
XcodeOCSnippets
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891