If you look at the exception, it tells you very precisely what's wrong:
You are trying to calling a 'length' method on an array, which simply does not exist. You want to use count
here instead. It's not in the code you posted, though - so just do a search for length
and you'll probably find it rather easily if the project isn't huge.
NSString *fPath = [documentsDirectory stringByAppendingPathComponent:locations];
gives you a warning, because locations
is an array. Think about it - just doesn't make sense: which of its elements do you want to add to the path?
As I think about it, both errors probably relate to each other: You simply ignored the compile time error - or warning - for the fPath, and now the stringByAppendingPathComponent:
method calls length on its parameter, which is a method of the expected NSString
.
Bottom line: Do not ignore compiler warnings! If you fix those, you probably reduce crashes, too.