Note that there are some explanatory texts on larger screens.

plurals
  1. POImplementing an NSOutlineView to edit the contents of a plist file
    primarykey
    data
    text
    <p>I'm writing a game using cocos2d-iphone and our stages are defined in .plist files. However, the files are growing large - so I've developed an editor that adds some structure to the process and breaks most of the plist down into fixed fields. However, some elements still require plist editor type functionality, so I have implemented an NSOutlineView on the panels that show 'other parameters'. I am attempting to duplicate the functionality from XCode's 'Property List Editor'.</p> <p>I've implemented the following system; <a href="http://www.stupendous.net/archives/2009/01/11/nsoutlineview-example/" rel="nofollow">http://www.stupendous.net/archives/2009/01/11/nsoutlineview-example/</a></p> <p>This is very close to what I need, but there is a problem that I've spent most of today attempting to solve. Values for the key column are calculated 'backwards' from the selected item by finding the parent dictionary and using;</p> <pre><code>return [[parentObject allKeysForObject:item] objectAtIndex:0]; </code></pre> <p>However, when there are multiple items with the same value within a given dictionary in the tree, this statement always returns the first item that has that value (it appears to compare the strings using isEqualToString: or hash values). This leads to the key column showing 'item1, item1, item1' instead of item1, item2, item3 (where items 1-3 all have value ''). I next tried;</p> <pre><code>-(NSString*)keyFromDictionary:(NSDictionary*)dict forItem:(id)item { for( uint i = 0; i &lt; [[dict allKeys] count]; i++ ) { id object = [dict objectForKey:[[dict allKeys] objectAtIndex:i]]; if ( &amp;object == &amp;item ) { return [[dict allKeys] objectAtIndex:i]; } } return nil; } </code></pre> <p>But this always returns <strong>nil</strong>. I was hoping that somebody with a bit more experience with NSOutlineView might be able to provide a better solution. While this problem only appears once in the linked example, I've had to use this a number of times when deleting items from dictionaries for instance. Any help would be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload