Sorry to ask something that others have already asked. But when I use the published fix, my program bombs
Original that works but gives the NSString deprecated message:
textFromFile = [NSString stringWithContentsOfFile:filePath];
tempArray=[NSMutableArray arrayWithArray:[textFromFile componentsSeparatedByString: @"||"]];
The reported fix:
NSString *textFromFile = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
tempArray=[NSMutableArray arrayWithArray:[textFromFile componentsSeparatedByString: @"||"]];
Bottom one bombs. What else about the fix am I missing?
(I am using NSString *textFromFile at the top of the file. My (beginner’s) intuition is that I am declaring it twice, but if I don’t put it at the top of the file, I get undeclared variable error messages. I know I’m not grasping something. Any words of wisdom would be appreciated.)
I have found the problem with my situation. Here it is for anyone else who runs into the same issue.
In the text file which was read into the string textFromFile, I had used || to separate the items that were then to be transferred into the tempArray.
The old deprecated way worked. The new, officially preferred method, with that extra encoding parameter, bombed.
When I switched the separators to jj instead of ||, the new method worked.
I now have no warnings about using deprecated syntax.