Home » iPhone, iPhone Programming, Programming

Solving plist ‘Invalid Summary’ error

4 July 2011 514 views No Comment

If you are doing something like the following:

NSString *path = [[NSBundle mainBundle] pathForResource:@”MenuStructure” ofType:@”plist”];

self.menuItems = [NSArray arrayWithContentsOfFile:path];

and run into problems resulting in an empty array which upon examination using breakpoints shows ‘Invalid Array’. U should check the following:

1. That the path is correct. if u use NSLog to print the path to the console or use the contextual info from the path then you will be told were your app is located. This would work best using they simulator because you will actually be able to navigate to the files. If you are running this on the device, you will be able to download the app directory however it removes the bundle directory (The folder with the executable and plists that you want to inspect!).

Doing this is especially useful if you suspect that locali(s/z)ation may the source of your woes. When doing this I realised that the localisation files/folders that I thought I’d removed via the minus option in xcode were still present. I found also that by cleaning the project (product>clean or Shift+CMD+K) that these unwanted files and folders were removed to reflect the correct layout.

2. The most likely cause is that the plist is not arranged in the format that you accessing it in. I.E it is laid out as a dictionary and you are using code like the above to move contents into an array (this may happen in reverse also). To check, right click the plist in the navigation pane and select open as>Source Code to view the XML.

If it reads:

<?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>sectionChildren</key>
<array></array> or <dict></dict>

</dict>
</plist>

Then the plists root object is a dictionary and is the reason for the error. Just change this to an array by removing the keys and changing the outermost <dict> and </dict> to <array> and </array>. I’m not sure and haven’t tested if this error would also occur if the root object was a string, number, or date etc.

 

 

 

 

</dict>

 

change the

 

 

 

 

 

0 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 5 (0 votes, average: 0.00 out of 5)
You need to be a registered member to rate this post.
Loading ... Loading ...

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.