In order for my user to easily edit a plist file, I want to present it into a NSTextView. It is a (mutable) array of (mutable) dictionaries converted in lines (one line per dictionary) of words separated with tabs (the keys). So, for example:
lastname1 firstname1
lastname2 firstname2
…
I already have my plist presented in such a text, I did so:
My problem is: how to put back the modified text into the dictionary? I tried this – of course everything freezes:
[__NSCFString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x7f83c5132f80
It was not a strict code error, it was a problem with bindings. You replaced the line
NSString *tempText = self.convertedText;
with
NSString *tempText = @"One\tTwo\nThree\tFour";
so the error had to come from here. convertedText was bound to the text view’s attributedString. As soon as I edited something, the app just looked like the Death Star at the end of the movie.
I replaced this line with NSString *tempText = [theTextView string]; and everything works fine now. I just had to put these records into an array and add:
[dictionary setObject: forKey:];
What a relief. I couldn’t figure out what was wrong in the code.