1

i want to load a plist into a nsdictionary with this code:

NSDictionary *data = [[NSDictionary alloc] initWithContentsOfURL:myUrl];

My Problem is that initWithContentsOfURL returns nil.

Here's a cutted version of my 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>copyright</key>
            <string>Copyright by XXX</string>

            <key>list</key>
            <dict>
                    <key>101</key>
                    <dict>
                            <key>name</key>
                            <string>club</string>

                            <key>data</key>         
                            <dict>
                                    <key>field</key>
                                    <dict>
                                            <key>field</key>
                                            <string>Course</string>

                                            <key>id</key>
                                            <integer>36</integer>

                                            <key>slop</key>
                                            <dict>
                                                    <key>35</key>
                                                    <dict>
                                                            <key>Field</key>
                                                            <string>Rot</string>

                                                            <key>Color</key>
                                                            <string>#fe0202</string>

                                                            <key>Sl</key>
                                                            <integer>11</integer>

                                                            <key>C</key>
                                                            <integer>7,4</integer>

                                                            <key>P</key>
                                                            <integer>71</integer>
                                                    </dict> 
                                            </dict>

                                            <key>1</key>
                                            <dict>
                                                    <key>h</key>
                                                    <integer>9</integer>

                                                    <key>p</key>
                                                    <integer>4</integer>
                                            </dict> 
                                    </dict>
                            </dict>

                            <key>last</key>
                            <string>2012-09-25 12:53:17</string>   
                    </dict>     
            </dict>
        </dict>
</plist>

When i'm loading the plist into a nsstring everthing works fine. Also there is a second plist without the stuff of the "slop" key. When i'm using that one i'm getting the dictionary.

Does anyone know what to do?

bluerob
  • 91
  • 7
  • What is there in myUrl? – kalyani puvvada Sep 13 '13 at 13:26
  • The problem is in your plist. Line 39 => `7,4` which of course is not an `int` and so the parser is throwing an error. – Alladinian Sep 13 '13 at 13:26
  • Can you view the plist in Xcode? Not as source, as a formatted display. – Wain Sep 13 '13 at 13:27
  • @alladinian ah annoying bug :/ so i have to use real instead of integer? thank you :) – bluerob Sep 13 '13 at 13:34
  • @bluerob Exactly. You can see the available [tags for CF types here](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFPropertyLists/Articles/XMLTags.html#//apple_ref/doc/uid/20001172-102719-BBCGIJIH) – Alladinian Sep 13 '13 at 13:35

0 Answers0