我在更改項目名稱後遇到(我認爲)命名空間問題。以下是錯誤:爲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中並且希望保持它在那裏設置。 –