First let me say that yes, I know that there are probably better ways to read a file than this. But the file I need to read in this case is a data file that must be shared with Windows (so I need access to the actual bytes to do endian conversions on OSX), and I need to jump to random locations in the file (as many as 1000 every time it's open).
Now, my question:
My app has been crashing at a specific location. I've managed to narrow the line it's crashing on down. If I take everything out of my function except these three lines, I see the crash:
If I remove the call to closeFile, the app no longer crashes. Now, I don't want to leave the file dangling open, or leave the handle unreleased, so my question is: Is handle going to be autoreleased when this function returns? And if so, will the file automatically be closed? If it will, I'm more than happy to leave the crashing closeFile call a mystery and move on.
Now, my question:
My app has been crashing at a specific location. I've managed to narrow the line it's crashing on down. If I take everything out of my function except these three lines, I see the crash:
Code:
NSFileHandle *handle = [NSFileHandle fileHandleForReadingAtPath:somepath];
[handle closeFile];
return @"somevalue"; //crash here
If I remove the call to closeFile, the app no longer crashes. Now, I don't want to leave the file dangling open, or leave the handle unreleased, so my question is: Is handle going to be autoreleased when this function returns? And if so, will the file automatically be closed? If it will, I'm more than happy to leave the crashing closeFile call a mystery and move on.