- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在保存 NSPersistentDocument 时遇到了奇怪的行为。我可以创建一个自动保存的新文档,没有问题。但是当我保存它时 write(to: ofType: for:absoluteOriginalContentsURL:)
被调用,但它变成了 configurePersistentStoreCoordinator(for: ofType: modelConfiguration: storeOptions:)
不是' t 打电话来。不幸的是,因为我需要配置商店。原因是我需要将 NSColor 注册为可解码 options[NSBinaryStoreSecureDecodingClasses] = NSSet(object: NSColor.self)
。
第一次尝试是自己调用它,但这并没有引导我到任何地方。自己调用它并没有按预期注册设置。
我的 NSPersistentDocument 中的代码如下所示:
override func configurePersistentStoreCoordinator(for url: URL, ofType fileType: String, modelConfiguration configuration: String?, storeOptions: [String : Any]? = nil) throws {
Swift.print("VTDocment.configurePersistentStoreCoordinator for \(url.lastPathComponent)")
var options = addOptions(to: storeOptions)
try super.configurePersistentStoreCoordinator(for: url, ofType: fileType, modelConfiguration: configuration, storeOptions: options)
}
func addOptions(to: [String : Any]?) -> [String : Any] {
var options = to != nil ? to! : [String:Any]()
if #available(OSX 10.13, *) {
options[NSBinaryStoreSecureDecodingClasses] = NSSet(object: NSColor.self)
}
options[NSMigratePersistentStoresAutomaticallyOption] = true
options[NSInferMappingModelAutomaticallyOption] = true
return options
}
override func write(to url: URL, ofType typeName: String, for saveOperation: NSDocument.SaveOperationType, originalContentsURL absoluteOriginalContentsURL: URL?) throws {
try self.configurePersistentStoreCoordinator(for: url, ofType: typeName, modelConfiguration: "Document")
do {
Swift.print("Now... VTDocment.write to \(url.lastPathComponent)")
try super.write(to: url, ofType: typeName, for: saveOperation, originalContentsURL: absoluteOriginalContentsURL)
} catch {
Swift.print("VTDocment.write error: \(error)")
}
}
结果是以下输出(第二个 configurePersistentStoreCoordinator 输出在通过菜单命令另存为后开始):
VTDocment.configurePersistentStoreCoordinator for Unsaved Visual Thinking with IBIS Document 12.ibisVT
VTDocment.configurePersistentStoreCoordinator for test.ibisVT
Now... VTDocment.write to test.ibisVT
value for key 'NS.objects' was of unexpected class 'NSColor'. Allowed classes are '{(
NSNumber,
NSString,
NSCalendarDate,
NSOrderedSet,
NSDecimalNumber,
NSUUID,
NSDate,
NSSet,
NSNull,
NSURL,
NSData,
NSDictionaryMapNode,
NSDictionary,
NSArray
)}'.
(null)
105827995370488
2018-02-09 05:53:52.250312+0100 Visual Thinking with IBIS[42589:19295813] -[NSException initialize]: unrecognized selector sent to instance 0x60400025d7c0
value for key 'NS.objects' was of unexpected class 'NSColor'. Allowed classes are '{(
NSNumber,
NSString,
NSCalendarDate,
NSOrderedSet,
NSDecimalNumber,
NSUUID,
NSDate,
NSSet,
NSNull,
NSURL,
NSData,
NSDictionaryMapNode,
NSDictionary,
NSArray
)}'.
编辑感谢@Tora 的提问!这是相关的堆栈跟踪。它不是来自同一个 session ,但会导致相同的结果。
0 CoreFoundation 0x00007fff40f9ffcb __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fff67c41c76 objc_exception_throw + 48
2 Foundation 0x00007fff430ef08f -[NSCoder(Exceptions) __failWithExceptionName:errorCode:format:] + 0
3 Foundation 0x00007fff430ef20c -[NSCoder(Exceptions) __failWithExceptionName:errorCode:format:] + 381
4 Foundation 0x00007fff43017555 -[NSCoder _validateAllowedClass:forKey:allowingInvocations:] + 239
5 Foundation 0x00007fff42fd948c _decodeObjectBinary + 1944
6 Foundation 0x00007fff42fdaa6f -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1945
7 Foundation 0x00007fff42fde8c5 -[NSArray(NSArray) initWithCoder:] + 202
8 Foundation 0x00007fff42fd9523 _decodeObjectBinary + 2095
9 Foundation 0x00007fff42fd8bee _decodeObject + 417
10 Foundation 0x00007fff42ff171b -[NSKeyedUnarchiver decodeObjectOfClasses:forKey:] + 409
11 CoreData 0x00007fff40b77491 -[NSDictionaryMapNode initWithCoder:] + 97
12 Foundation 0x00007fff42fd9523 _decodeObjectBinary + 2095
13 Foundation 0x00007fff42fdaa6f -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1945
14 Foundation 0x00007fff42fd9de8 -[NSDictionary(NSDictionary) initWithCoder:] + 202
15 Foundation 0x00007fff42fd9523 _decodeObjectBinary + 2095
16 Foundation 0x00007fff42fd8bee _decodeObject + 417
17 Foundation 0x00007fff42ff171b -[NSKeyedUnarchiver decodeObjectOfClasses:forKey:] + 409
18 CoreData 0x00007fff40bcfcc2 -[NSBinaryObjectStoreFile readBinaryStoreFromData:originalPath:error:] + 994
19 CoreData 0x00007fff40bd019a -[NSBinaryObjectStoreFile readFromFile:error:] + 474
20 CoreData 0x00007fff40aed247 -[NSDictionaryStoreMap initWithStore:fromPath:] + 215
21 CoreData 0x00007fff40b75bd3 -[NSBinaryObjectStore initWithPersistentStoreCoordinator:configurationName:URL:options:] + 739
22 CoreData 0x00007fff40b56e35 __91-[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:]_block_invoke + 1845
23 CoreData 0x00007fff40b69132 gutsOfBlockToNSPersistentStoreCoordinatorPerform + 210
24 CoreData 0x00007fff40b52f75 _perform + 213
25 CoreData 0x00007fff40a7d2cf -[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:] + 559
26 CoreData 0x00007fff40b596e4 __84-[NSPersistentStoreCoordinator migratePersistentStore:toURL:options:withType:error:]_block_invoke + 1284
27 CoreData 0x00007fff40b69132 gutsOfBlockToNSPersistentStoreCoordinatorPerform + 210
28 libdispatch.dylib 0x00007fff687f7d50 _dispatch_client_callout + 8
29 libdispatch.dylib 0x00007fff6880b1d6 _dispatch_queue_barrier_sync_invoke_and_complete + 60
30 CoreData 0x00007fff40b52f62 _perform + 194
31 CoreData 0x00007fff40b590ef -[NSPersistentStoreCoordinator migratePersistentStore:toURL:options:withType:error:] + 351
32 AppKit 0x00007fff3ebc8fd6 -[NSPersistentDocument writeToURL:ofType:forSaveOperation:originalContentsURL:error:] + 2367
33 Visual Thinking with IBIS 0x000000010003edb2 _T025Visual_Thinking_with_IBIS10VTDocumentC5writey10Foundation3URLV2to_SS6ofTypeSo10NSDocumentC013SaveOperationK0O3forAGSg016originalContentsH0tKF + 1570
34 Visual Thinking with IBIS 0x000000010003f22c _T025Visual_Thinking_with_IBIS10VTDocumentC5writey10Foundation3URLV2to_SS6ofTypeSo10NSDocumentC013SaveOperationK0O3forAGSg016originalContentsH0tKFTo + 284
35 AppKit 0x00007fff3f0996aa -[NSDocument(NSDocumentSaving) _writeSafelyToURL:ofType:forSaveOperation:forceTemporaryDirectory:error:] + 870
36 AppKit 0x00007fff3f09a394 -[NSDocument(NSDocumentSaving) _writeSafelyToURL:ofType:forSaveOperation:error:] + 28
37 AppKit 0x00007fff3ebc9eb3 -[NSPersistentDocument writeSafelyToURL:ofType:forSaveOperation:error:] + 446
38 AppKit 0x00007fff3f0a5294 __85-[NSDocument(NSDocumentSaving) _saveToURL:ofType:forSaveOperation:completionHandler:]_block_invoke_2.1146 + 238
39 AppKit 0x00007fff3f0a5197 __85-[NSDocument(NSDocumentSaving) _saveToURL:ofType:forSaveOperation:completionHandler:]_block_invoke.1143 + 454
40 AppKit 0x00007fff3f0a33ff __85-[NSDocument(NSDocumentSaving) _saveToURL:ofType:forSaveOperation:completionHandler:]_block_invoke_3.999 + 1962
41 AppKit 0x00007fff3eae0eb4 -[NSDocument(NSDocumentSerializationAPIs) continueFileAccessUsingBlock:] + 238
42 AppKit 0x00007fff3f0a04b9 __119-[NSDocument(NSDocumentSaving) _fileCoordinator:asynchronouslyCoordinateReadingContentsAndWritingItemAtURL:byAccessor:]_block_invoke_2 + 94
43 AppKit 0x00007fff3ea5f8c0 __62-[NSDocumentController(NSInternal) _onMainThreadInvokeWorker:]_block_invoke.2153 + 157
44 CoreFoundation 0x00007fff40f3858c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
45 CoreFoundation 0x00007fff40f1b043 __CFRunLoopDoBlocks + 275
46 CoreFoundation 0x00007fff40f1ae08 __CFRunLoopRun + 3128
47 CoreFoundation 0x00007fff40f19f43 CFRunLoopRunSpecific + 483
48 HIToolbox 0x00007fff40231e26 RunCurrentEventLoopInMode + 286
49 HIToolbox 0x00007fff40231b96 ReceiveNextEventCommon + 613
50 HIToolbox 0x00007fff40231914 _BlockUntilNextEventMatchingListInModeWithFilter + 64
51 AppKit 0x00007fff3e4fcf5f _DPSNextEvent + 2085
52 AppKit 0x00007fff3ec92b4c -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 3044
53 AppKit 0x00007fff3e4f1d6d -[NSApplication run] + 764
54 AppKit 0x00007fff3e4c0f1a NSApplicationMain + 804
55 Visual Thinking with IBIS 0x0000000100019bed main + 13
56 libdyld.dylib 0x00007fff68831115 start + 1
提前非常感谢。
更新Tora 的解决方案(通过方法调配)效果很好。但是,有时(不确定何时)可能会导致相同的问题。这是更新的堆栈跟踪。这很神秘。 :-)
0 CoreFoundation 0x00007fff40f9ffcb __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fff67c41c76 objc_exception_throw + 48
2 Foundation 0x00007fff430ef08f -[NSCoder(Exceptions) __failWithExceptionName:errorCode:format:] + 0
3 Foundation 0x00007fff430ef20c -[NSCoder(Exceptions) __failWithExceptionName:errorCode:format:] + 381
4 Foundation 0x00007fff43017555 -[NSCoder _validateAllowedClass:forKey:allowingInvocations:] + 239
5 Foundation 0x00007fff42fd948c _decodeObjectBinary + 1944
6 Foundation 0x00007fff42fdaa6f -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1945
7 Foundation 0x00007fff42fde8c5 -[NSArray(NSArray) initWithCoder:] + 202
8 Foundation 0x00007fff42fd9523 _decodeObjectBinary + 2095
9 Foundation 0x00007fff42fd8bee _decodeObject + 417
10 Foundation 0x00007fff42ff171b -[NSKeyedUnarchiver decodeObjectOfClasses:forKey:] + 409
11 CoreData 0x00007fff40b77491 -[NSDictionaryMapNode initWithCoder:] + 97
12 Foundation 0x00007fff42fd9523 _decodeObjectBinary + 2095
13 Foundation 0x00007fff42fdaa6f -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1945
14 Foundation 0x00007fff42fd9de8 -[NSDictionary(NSDictionary) initWithCoder:] + 202
15 Foundation 0x00007fff42fd9523 _decodeObjectBinary + 2095
16 Foundation 0x00007fff42fd8bee _decodeObject + 417
17 Foundation 0x00007fff42ff171b -[NSKeyedUnarchiver decodeObjectOfClasses:forKey:] + 409
18 CoreData 0x00007fff40bcfcc2 -[NSBinaryObjectStoreFile readBinaryStoreFromData:originalPath:error:] + 994
19 CoreData 0x00007fff40bd019a -[NSBinaryObjectStoreFile readFromFile:error:] + 474
20 CoreData 0x00007fff40aed247 -[NSDictionaryStoreMap initWithStore:fromPath:] + 215
21 CoreData 0x00007fff40b75bd3 -[NSBinaryObjectStore initWithPersistentStoreCoordinator:configurationName:URL:options:] + 739
22 CoreData 0x00007fff40b56e35 __91-[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:]_block_invoke + 1845
23 CoreData 0x00007fff40b69132 gutsOfBlockToNSPersistentStoreCoordinatorPerform + 210
24 CoreData 0x00007fff40b52f75 _perform + 213
25 CoreData 0x00007fff40a7d2cf -[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:] + 559
26 CoreData 0x00007fff40b596e4 __84-[NSPersistentStoreCoordinator migratePersistentStore:toURL:options:withType:error:]_block_invoke + 1284
27 CoreData 0x00007fff40b69132 gutsOfBlockToNSPersistentStoreCoordinatorPerform + 210
28 libdispatch.dylib 0x00007fff687f7d50 _dispatch_client_callout + 8
29 libdispatch.dylib 0x00007fff6880b1d6 _dispatch_queue_barrier_sync_invoke_and_complete + 60
30 CoreData 0x00007fff40b52f62 _perform + 194
31 CoreData 0x00007fff40b590ef -[NSPersistentStoreCoordinator migratePersistentStore:toURL:options:withType:error:] + 351
32 AppKit 0x00007fff3ebc8fd6 -[NSPersistentDocument writeToURL:ofType:forSaveOperation:originalContentsURL:error:] + 2367
33 Visual Thinking with IBIS 0x00000001000404a2 _T025Visual_Thinking_with_IBIS10VTDocumentC5writey10Foundation3URLV2to_SS6ofTypeSo10NSDocumentC013SaveOperationK0O3forAGSg016originalContentsH0tKF + 1570
34 Visual Thinking with IBIS 0x000000010004091c _T025Visual_Thinking_with_IBIS10VTDocumentC5writey10Foundation3URLV2to_SS6ofTypeSo10NSDocumentC013SaveOperationK0O3forAGSg016originalContentsH0tKFTo + 284
35 AppKit 0x00007fff3f0996aa -[NSDocument(NSDocumentSaving) _writeSafelyToURL:ofType:forSaveOperation:forceTemporaryDirectory:error:] + 870
36 AppKit 0x00007fff3f09a394 -[NSDocument(NSDocumentSaving) _writeSafelyToURL:ofType:forSaveOperation:error:] + 28
37 AppKit 0x00007fff3ebc9eb3 -[NSPersistentDocument writeSafelyToURL:ofType:forSaveOperation:error:] + 446
38 AppKit 0x00007fff3f0a5294 __85-[NSDocument(NSDocumentSaving) _saveToURL:ofType:forSaveOperation:completionHandler:]_block_invoke_2.1146 + 238
39 AppKit 0x00007fff3f0a5197 __85-[NSDocument(NSDocumentSaving) _saveToURL:ofType:forSaveOperation:completionHandler:]_block_invoke.1143 + 454
40 AppKit 0x00007fff3f0a33ff __85-[NSDocument(NSDocumentSaving) _saveToURL:ofType:forSaveOperation:completionHandler:]_block_invoke_3.999 + 1962
41 AppKit 0x00007fff3eae0eb4 -[NSDocument(NSDocumentSerializationAPIs) continueFileAccessUsingBlock:] + 238
42 AppKit 0x00007fff3f0a04b9 __119-[NSDocument(NSDocumentSaving) _fileCoordinator:asynchronouslyCoordinateReadingContentsAndWritingItemAtURL:byAccessor:]_block_invoke_2 + 94
43 AppKit 0x00007fff3ea5f8c0 __62-[NSDocumentController(NSInternal) _onMainThreadInvokeWorker:]_block_invoke.2153 + 157
44 CoreFoundation 0x00007fff40f3858c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
45 CoreFoundation 0x00007fff40f1b043 __CFRunLoopDoBlocks + 275
46 CoreFoundation 0x00007fff40f1ae08 __CFRunLoopRun + 3128
47 CoreFoundation 0x00007fff40f19f43 CFRunLoopRunSpecific + 483
48 HIToolbox 0x00007fff40231e26 RunCurrentEventLoopInMode + 286
49 HIToolbox 0x00007fff40231b96 ReceiveNextEventCommon + 613
50 HIToolbox 0x00007fff40231914 _BlockUntilNextEventMatchingListInModeWithFilter + 64
51 AppKit 0x00007fff3e4fcf5f _DPSNextEvent + 2085
52 AppKit 0x00007fff3ec92b4c -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 3044
53 AppKit 0x00007fff3e4f1d6d -[NSApplication run] + 764
54 AppKit 0x00007fff3e4c0f1a NSApplicationMain + 804
55 Visual Thinking with IBIS 0x000000010001a3dd main + 13
56 libdyld.dylib 0x00007fff68831115 start + 1
最佳答案
另一种更简单的解决方法:
下面的代码有一个错误。请参阅下面引用的错误修复版本。
extension NSPersistentStoreCoordinator {
@objc func x_migratePersistentStore(_ store: NSPersistentStore, to URL: URL, options: [AnyHashable : Any]? = nil, withType storeType: String) throws -> NSPersistentStore {
var opt: [AnyHashable : Any] = options ?? [:]
if #available(OSX 10.13, *) {
opt[NSBinaryStoreSecureDecodingClasses] = NSSet(array: [ NSColor.self ])
}
return try x_migratePersistentStore(store, to: URL, options: opt, withType: storeType)
}
}
class Document: NSPersistentDocument {
override init() {
super.init()
let s1 = #selector(NSPersistentStoreCoordinator.migratePersistentStore(_:to:options:withType:))
let s2 = #selector(NSPersistentStoreCoordinator.x_migratePersistentStore(_:to:options:withType:))
let m1 = class_getInstanceMethod(NSPersistentStoreCoordinator.self, s1)!
let m2 = class_getInstanceMethod(NSPersistentStoreCoordinator.self, s2)!
method_exchangeImplementations(m1, m2)
}
override func configurePersistentStoreCoordinator(for url: URL, ofType fileType: String, modelConfiguration configuration: String?, storeOptions: [String : Any]? = nil) throws {
// keep yours
}
}
已添加:
此解决方法将成为一个实用的解决方案,直到他们增强 NSPersistentDocument.write(to...)
以考虑选项或实现其他方法来处理选项。这些选项将提供给 NSPersistentStoreCoordinator.migratePercientStore(...)
,然后用于实例化 NSPersistentStore
。
错误修复版本:
前面的解决方法中存在错误。打开文档文件、创建新文件、进行更改、等待文档自动保存三十秒、关闭它们和/或随机另存为它们都会导致初始错误。由克努普巫师报道。
这是一个使用单例的固定版本,以确保仅应用一次混合。
extension NSPersistentStoreCoordinator {
@objc func x_migratePersistentStore(_ store: NSPersistentStore, to URL: URL, options: [AnyHashable : Any]? = nil, withType storeType: String) throws -> NSPersistentStore {
var opt: [AnyHashable : Any] = options ?? [:]
if #available(OSX 10.13, *) {
opt[NSBinaryStoreSecureDecodingClasses] = NSSet(array: [ NSColor.self ])
}
return try x_migratePersistentStore(store, to: URL, options: opt, withType: storeType)
}
class MigratePersistentStoreInitializer {
init() {
let s1 = #selector(NSPersistentStoreCoordinator.migratePersistentStore(_:to:options:withType:))
let s2 = #selector(NSPersistentStoreCoordinator.x_migratePersistentStore(_:to:options:withType:))
let m1 = class_getInstanceMethod(NSPersistentStoreCoordinator.self, s1)!
let m2 = class_getInstanceMethod(NSPersistentStoreCoordinator.self, s2)!
method_exchangeImplementations(m1, m2)
}
static let singlton = MigratePersistentStoreInitializer() // Lazy Stored Property
}
}
class Document: NSPersistentDocument {
override init() {
super.init()
let _ = NSPersistentStoreCoordinator.MigratePersistentStoreInitializer.singlton
}
override func configurePersistentStoreCoordinator(for url: URL, ofType fileType: String, modelConfiguration configuration: String?, storeOptions: [String : Any]? = nil) throws {
// keep yours
}
}
引用文献:
关于macos - 未调用 configurePersistentStoreCoordinator 来保存 NSPersistentDocument,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48699000/
我的应用程序当前使用 CoreData 作为后端来存储到存储在 ~/Library/Application Support/MYAPP/MyDataFile.sqlite 中的单个 SQL 数据文件。
我想设置 NSPersistentDocument 对象窗口的一些属性。我如何访问它? 还有比这样更好的方法吗? [[[[self windowControllers] objectAtInd
ALM 很棒。但是我无法让它在使用带有 NSDocument 的 Core Data 的项目上工作。似乎默认情况下禁用了 ALM。 美好的。对于任何普通项目,您需要在此行的字典中添加两个适当的选项:
我有一个基于 NSPersistentDocument 的应用程序,它根据不同的条件和数据具有三个不同的 View ,并且每个 View 都工作正常。 现在客户还想从 shell 脚本运行应用程序。
我刚刚创建了一个新的核心数据文档应用程序,并且在提供的模板中(只有 NSPersistentDocument 子类和模型),我想坚持 - (BOOL)applicationShouldTerminat
我已经对 NSPersistentDocument 进行了子类化。我也重新命名了窗口。但是当我运行应用程序时,我得到应用程序窗口的标题为“无标题”。没有可用于更改标题的 -setTitle: 方法。我
我创建了一个使用实体模型构建器及其相关内容的 OSX 应用程序,为简单起见,请考虑只有两个 NSString 的实体。 该应用程序正在生产中并且工作正常,现在我需要向现有实体添加新属性(仅存在一个实体
似乎有关于在基于文档的应用程序中使用核心数据的信息。我有一个窗口 Controller ,在当前文档中运行模式窗口。用户将数据输入到文本字段中,该字段创建一个可变的字符串数组,我想用它来创建模型对象(
我正在考虑制作一个基于核心数据的以文档为中心的应用程序,但我希望保存的文件格式是我自己专有的 XML、图像和其他内容包。 我的计划是使用 NSPersistentDocument 的子类,当收到 -w
因为我使用的是自定义核心数据堆栈,所以我将覆盖 init、readFromURL、writeToURL 和 revertToContentsOfURL 函数。 当我单击“浏览所有版本”时,文件的先前版
我正在尝试使用我觉得相对舒服的 OCUnit/SenTest 框架编写集成测试。该测试是关于 NSPersistentDocument 子类的加载,该子类依赖于成功导入的 CoreData 托管对象模
我正在尝试对 Core Data 中的 SQLite 存储进行轻量级迁移。使用 Xcode 4.3.1 在 Lion 10.7.3 上工作。 在我的 NSPersistentDocument 子类 (
我的基于 Core Data 文档的应用程序在“另存为”时崩溃。该问题似乎与标题为“NSPersistentDocument objects "gutted" after Duplicate, Ren
我在保存 NSPersistentDocument 时遇到了奇怪的行为。我可以创建一个自动保存的新文档,没有问题。但是当我保存它时 write(to: ofType: for:absoluteOrig
使用 NSPersistentDocument 加载现有文档时,作为初始化的一部分,我想准备一些内容: NSFetchRequest *req = [NSFetchRequest fetchR
我正在尝试使用 Lion 中的新沙箱规则使 Mac 应用程序保持最新状态。但是,尽管请求了 com.apple.security.files.user-selected.read-write 权限,但
这里是核心数据新手。我正在尝试更改 NSPersistentDocument 的默认 NSManagedObjectContext,以便初始化它并将其与 NSMainQueueConcurrencyT
我在 NSPersistentDocument 窗口中有一个 NSTextView。我将文本字段的内容绑定(bind)到“二进制数据”核心数据字段,但是当我在 TextView 中键入文本时,文档的标
我想创建一个使用 swift 核心数据 以标准 macOS 方式工作的“文档”[自定义扩展名,包含与该文档相关的所有数据的单个"file"/文件包装器] 这似乎是不可能的。该文件非常清楚地说明 NSP
我使用 Xcode 9.2 创建了一个全新的 macOS 应用,并在项目模板中选择了“创建基于文档的应用程序”和“使用核心数据”。 我做了四项更改: 编辑 CoreData 模型以添加一个名为“Ent
我是一名优秀的程序员,十分优秀!