I’ve written a method to access a nested dictionary stored in a plist. Works fine on the 10.8 compiler but I get the following error on the 10.7 compiler:
Expected method to read dictionary element not found on object type ‘NSDictionary*’
The plist has the following structure:
<dict>
<key>15.144.15</key>
<dict>
<key>Message</key>
<string>15</string>
<key>X</key>
<real>484.8828125</real>
<key>Y</key>
<real>104</real>
</dict>
<key>15.144.17</key>
<dict>
<key>Message</key>
<string>17</string>
<key>X</key>
<real>612.91796875</real>
<key>Y</key>
<real>190.6484375</real>
</dict>
</dict>
Here’s the code I’m using to access the nested values for Message, X and Y:
NSString * value = [dictionaryFromPlist][parentKey][nestedKey];
I’m assuming that the 10.8 SDK handles accessing nested dictionaries in this way but 10.7 doesn’t.
Anyone know a method that will be compatible with both SDKs?
Thanks
Compile with the 10.8 SDK and set your deployment target to 10.7. This is backward-deployable to 10.6. Your syntax is wrong, tho. Don’t surround the variable name in brackets, just the subscript keys: