开发者

Receiving a SIGABRT when accessing NSDictionary

开发者 https://www.devze.com 2023-04-07 10:52 出处:网络
When using a NSDictionary that navigates to a PLIST I keep on getting an SIGABRT error, **2011-09-26 18:31:01.740 AlarmAppiPhone[3126:10d03] -[__NSCFArray _isNaturallyRTL]: unrecognized selector sen

When using a NSDictionary that navigates to a PLIST I keep on getting an SIGABRT error,

**2011-09-26 18:31:01.740 AlarmAppiPhone[3126:10d03] -[__NSCFArray _isNaturallyRTL]: unrecognized selector sent to instance 0x5cb5090
2011-09-26 18:31:01.742 AlarmAppiPhone[3126:10d03] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFArray _isNaturallyRTL]: unrecognized selector sent to instance 0x5cb5090'**

at this line, editLabelTextField.text = [alarm objectForKey:ROOT_KEY]; I don't know why I am getting this. The alarm is a NSDictionary and it uses object for key to navigate to a key which I have declared like this, #define ROOT_KEY @"Root". I defined it in another file. The plist looks somewhat like this,

<?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>Root</key>
    <array>
        <dict>
            <key>label</key>
            <string>alarm1</string>
            <ke开发者_JAVA技巧y>time</key>
            <date>2011-09-03T07:24:20Z</date>
        </dict>
        <dict>
            <key>label</key>
            <string>alarm2</string>
            <key>time</key>
            <string>2011-09-03T07:24:14Z</string>
        </dict>
    </array>
</dict>
</plist>


[alarm objectForKey:@"Root"] returns an NSArray, which you're trying to assign to a property which expects an NSString. (_isNaturallyRTL is an iOS-specific, private function of NSString.)

I assume you're trying to get to the label. Structurally, such an access would look like this (your variable alarm should probably be called alarmPlist):

NSArray *alarms = [alarmPlist objectForKey:@"Root"];
NSDictionary *alarm = [alarms objectAtIndex:0];
editLabelTextField.text = [alarm objectForKey:@"label"];

Replace the 0 with a different index to access a different alarm.

0

精彩评论

暂无评论...
验证码 换一张
取 消