【问题标题】:Xcode 4 crashes when trying to add a new item to "Preference items" array in a settings bundle尝试将新项目添加到设置包中的“首选项”数组时,Xcode 4 崩溃
【发布时间】:2011-09-15 17:34:08
【问题描述】:

我为我的 iOS 应用创建了一个设置包并尝试编辑 Root.plist 文件。

我可以更改一些现有值(默认创建的值),但如果我尝试添加新项目(无论类型如何),Xcode 4 会崩溃并出现以下错误:

有人知道这可能是什么原因吗?

我正在使用 Xcode 4.02 build 4A2002a。 这是日志:

ASSERTION FAILURE in /SourceCache/DVTKit/DVTKit-221/Framework/Classes/PlistView/DVTPlistDictionaryNode.m:171
Details:  method -[DVTPlistDictionaryNode value] is inappropriate for instances of DVTPlistDictionaryNode
Object:   <DVTPlistDictionaryNode: 0x202442340>
Method:   -value
Thread:   <NSThread: 0x200020700>{name = (null), num = 1}
Hints:   None
Backtrace:
  0  0x0000000100949773 -[IDEAssertionHandler handleFailureInMethod:object:fileName:lineNumber:messageFormat:arguments:] (in IDEKit)
  1  0x000000010006d394 _DVTAssertionFailureHandler (in DVTFoundation)
  2  0x00000001002ed3cb -[DVTPlistDictionaryNode value] (in DVTKit)
  3  0x00000001002f0443 -[DVTPlistModel replacePlist:withPlist:] (in DVTKit)
  4  0x00000001003030d4 -[DVTPlistViewController outlineView:setObjectValue:forTableColumn:byItem:] (in DVTKit)
  5  0x00007fff8830e149 -[NSOutlineView _dataSourceSetValue:forColumn:row:] (in AppKit)
  6  0x00007fff883c4dd9 -[NSTableView performClickOnCellAtColumn:row:] (in AppKit)
  7  0x00007fff883c1200 -[NSTableView _attemptToPerformClickOnFocusedColumn] (in AppKit)
  8  0x00007fff86bd511c __NSFireDelayedPerform (in Foundation)
  9  0x00007fff867f5be8 __CFRunLoopRun (in CoreFoundation)
 10  0x00007fff867f3dbf CFRunLoopRunSpecific (in CoreFoundation)
 11  0x00007fff88f577ee RunCurrentEventLoopInMode (in HIToolbox)
 12  0x00007fff88f575f3 ReceiveNextEventCommon (in HIToolbox)
 13  0x00007fff88f574ac BlockUntilNextEventMatchingListInMode (in HIToolbox)
 14  0x00007fff87ec4e64 _DPSNextEvent (in AppKit)
 15  0x00007fff87ec47a9 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] (in AppKit)
 16  0x00007fff87e8a48b -[NSApplication run] (in AppKit)
 17  0x00007fff87e831a8 NSApplicationMain (in AppKit)
 18  0x0000000100000eec
 19  0x0000000000000002

这是Xcode自己创建的root.plist的内容:

<?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>PreferenceSpecifiers</key>
    <array>
        <dict>
            <key>Title</key>
            <string>Group</string>
            <key>Type</key>
            <string>PSGroupSpecifier</string>
        </dict>
        <dict>
            <key>AutocapitalizationType</key>
            <string>None</string>
            <key>AutocorrectionType</key>
            <string>No</string>
            <key>DefaultValue</key>
            <string></string>
            <key>IsSecure</key>
            <false/>
            <key>Key</key>
            <string>name_preference</string>
            <key>KeyboardType</key>
            <string>Alphabet</string>
            <key>Title</key>
            <string>Name</string>
            <key>Type</key>
            <string>PSTextFieldSpecifier</string>
        </dict>
        <dict>
            <key>DefaultValue</key>
            <true/>
            <key>Key</key>
            <string>enabled_preference</string>
            <key>Title</key>
            <string>Enabled</string>
            <key>Type</key>
            <string>PSToggleSwitchSpecifier</string>
        </dict>
        <dict>
            <key>DefaultValue</key>
            <real>0.5</real>
            <key>Key</key>
            <string>slider_preference</string>
            <key>MaximumValue</key>
            <integer>1</integer>
            <key>MaximumValueImage</key>
            <string></string>
            <key>MinimumValue</key>
            <integer>0</integer>
            <key>MinimumValueImage</key>
            <string></string>
            <key>Type</key>
            <string>PSSliderSpecifier</string>
        </dict>
    </array>
    <key>StringsTable</key>
    <string>Root</string>
</dict>
</plist>

【问题讨论】:

  • 你的 plist 的根元素是什么?它是字典(Xcode 似乎期待的)还是数组?
  • 它是一个数组(实际上可以在上图中看到)。 plist 是由 Xcode 自己创建的...
  • 我用文本编辑器检查了 root.plist,根元素是字典。您可能会在下面看到它。顺便说一句,这发生在所有项目中,而不仅仅是我的。
  • 奇数。在告诉 Xcode 不要崩溃后,你能继续使用它吗?有时这足以让我做我想做的事。如果一切都失败了,您可能会考虑使用 PlistBuddy 或默认值来操作您的 plist。 (Property List Editor.app 是理想的,但我认为它不包含在 Xcode 4 安装中。)
  • 如果我忽略崩溃,它似乎可以工作。如果您将此作为答案发布,我会接受。

标签: cocoa-touch xcode4 crash settings.bundle


【解决方案1】:

听起来像是 Apple 的错误。如果您告诉 Xcode 继续而不是崩溃,您可能能够继续工作,就好像没有出错一样。如果一切都失败了,您可能会考虑使用 PlistBuddy 或默认值来操作您的 plist。 (Property List Editor.app 是理想的,但我认为它不包含在 Xcode 4 安装中。)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-02
    • 1970-01-01
    相关资源
    最近更新 更多