contentsOfDirectoryAtPath returns items in a different order than in previous iOS. Any change in the underlining code of file system?
contentsOfDirectoryAtPath returns items in a different order
hi,
i ran into a variation of this problem a while ago, and i specifically noted for myself the need to sort the urls (thinking that the problem came from compiling on different machines):
if var availableURLs = myBundle.urls(forResourcesWithExtension: "json", subdirectory: "Session Formats JSON") {
// sort required -- turns out that compiling on a different machine might
// not put the JSON files in alphabetical order
availableURLs.sort() { $0.path < $1.path }i know you're using contentsOfDirectoryAtPath, but i just checked its documentation, under the Discussion section: "The order of the files in the returned array is undefined."
(so i did the right thing, but probably for the wrong reason.)
hope that helps,
DMG