Where’s my leçon?

A user reported that he inadvertently overwrote one of his documents because he accidentally used the same name when creating a new lesson.

He was wondering why there wasn’t some sort of warning to prevent this.

I clearly remember writing quite a bit of code in order to stop this very scenario from occurring so I did some investigating to find out what the problem was.

I noticed that the user was using document names that had special unicode characters (in this case a ‘ç’) so I checked the documentation to see if there was anything mentioned.  I use the standard isEqualToString: method to compare strings which does indeed clearly state:

The comparison uses the canonical representation of strings, which for a particular string is the length of the string plus the Unicode characters that make up the string. When this method compares two strings, if the individual Unicodes are the same, then the strings are equal, regardless of the backing store. “Literal” when applied to string comparison means that various Unicode decomposition rules are not applied and Unicode characters are individually compared. So, for instance, “Ö” represented as the composed character sequence “O” and umlaut would not compare equal to “Ö” represented as one Unicode character.

Whoops!  I’ve switched over to using localizedCompare: so you can expect the app to properly check document names from version 2.2.6:

It’ll also check when renaming documents:

I’m really sorry for any trouble this may have caused anyone and I’m greatly appreciative of the user that reported the issue.

Please do continue letting me know if you notice any strange behavior and I’ll continue improving things.

Happy studies!

One Reply to “Where’s my leçon?”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.