我在更改项目名称后遇到(我认为)命名空间问题。以下是错误:为OSX重命名Xcode项目后出现NSKeyedUnarchiver错误
Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: '* -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (Apple.Document) for key (NS.objects); the class may be defined in source code or a library that is not linked'
有一个类似的问题解决here,但这指的是iOS版。对于Mac,只需更改display bundle name
将不会更改在扩展坞图标下显示的名称。
从“苹果”到“梨花”, 改变我有问题,从CoreData越来越Document
对象时,项目名称后:
// Document
@objc(Document)
class Document: NSManagedObject {
@NSManaged var content: NSAttributedString
}
文档的content
包含SpecialTextAttachment
秒。
// SpecialTextAttachment
class SpecialTextAttachment: NSTextAttachment {
//
}
当打印文档的内容时,它给了我上面提到的错误。我将如何去转换Apple.SpecialTextAttachment
到Pear.SpecialTextAttachment
?看起来好像我需要在迭代Document
之前对其进行转换,因为只涉及到Document
类会导致崩溃。我也不能像建议here那样简单地为这个班级创建另一个项目。
// in ViewController
func getDocuments() {
let fetchRequest = NSFetchRequest()
fetchRequest.entity = NSEntityDescription.entityForName("Document", inManagedObjectContext: managedObjectContext!)
fetchRequest.fetchBatchSize = 20
let docs = (try? managedObjectContext!.executeFetchRequest(fetchRequest)) as! [Document]
}
谢谢,但是设置CFBundleDisplayName并没有改变任何东西。即使干净后。 –
你不需要在Info.plist中设置CFBundleDisplayName(我不建议你这么做)。我只说你需要在你的'InfoPlist.strings' **中设置**如果你有(因为某种原因)将它设置在你的Info.plist中并且希望保持它在那里设置。 –