The NSFileHandle class is an object-oriented wrapper for a file descriptor. You use file handle objects to access data associated with files, sockets, pipes, and devices. For files, you can read, write, and seek within the file. For sockets, pipes, and devices, you can use a file handle object to monitor the device and process data asynchronously.
Questions tagged [nsfilehandle]
139 questions
2
votes
1 answer
Downloading a video from a remote URL into device and streaming it via AVPlayer
What I'm doing currently is that, I have a remote URL containing a MP4 file. I download that into a file using NSData and NSFileManager (as I want to cache the file). Now I start to play the file using AVPlayer.
All this works. But the problem…

Anil
- 2,430
- 3
- 37
- 55
2
votes
0 answers
Why doesn't NSFileHandle throw an exception when file no longer exist
I am using NSFileHandle's fileHandleForWritingAtPath to open a handle to a file and write into it (append to the end of it). Since I always need to write into it I never close the handle or check that it's there when writing into it.
I need to…

user1730969
- 462
- 3
- 10
1
vote
0 answers
NSFileHandle and removing a section of bytes
I'm a bit surprised because I believe that there is no obvious way to delete a section of bytes of a file.
That is, suppose I have a file that holds 900 GB, and want to delete 8 bytes starting from offset 54.
Is there any way to do it without…

BIOS-K
- 146
- 1
- 9
1
vote
1 answer
[NSConcreteFileHandle writeData:]: Bad file descriptor - Crashes app on startup
I'm using GTMLogger and have the following piece of code that seems to be crashing since moving to iOS5.1 . The weird thing i can't seem to reproduce it, but i know its happening to many users, so I'm not sure how to track it.
[NSConcreteFileHandle…

Shai Mishali
- 9,224
- 4
- 56
- 83
1
vote
2 answers
I'm trying to find a file size. But my length is equl to zero
I'm trying to find a file size.
NSFileHandle *output = [NSFileHandle fileHandleForWritingAtPath:self.finalPath];
//seek to begin of the file
[output seekToFileOffset:0];
NSData *mydata = [output availableData];
NSLog(@"length: %d", [mydata…

Voloda2
- 12,359
- 18
- 80
- 130
1
vote
1 answer
"readInBackgroundAndNotify" increases retain count of receiver
I am using NSFileHandle to read data from a socket.
This is how I am creating the filehandle:
filehandle = [[NSFileHandle alloc] initWithFileDescriptor:sock
closeOnDealloc:YES];
I am doing this:
[[NSNotificationCenter defaultCenter]…

Shanti K
- 2,873
- 1
- 16
- 31
1
vote
1 answer
NSTask pipes output to Console rather than the NSFileHandle
I set up an NSNotification for NSFileHandleReadCompletionNotification.
I set up the standard I/O with two separate pipes.
NSPipe * input = NSPipe.new;
NSPipe * output = NSPipe.new;
[serverTask setStandardInput:input];
[serverTask…

evdude100
- 437
- 4
- 18
1
vote
2 answers
Objective C FileHandle's fileHandleWithStandardOutput
In the FileHandle Class there is a fileHandleWithStandardOutput method. According to the Documentation, "Conventionally this is a terminal device that receives a stream of data from a program."
What I want to do is read a file per 128 bytes and…

jovhenni19
- 450
- 2
- 8
- 24
1
vote
2 answers
How to use NSFileHandle to read integer from file
I want to read a list of integers from a text file, I just want to write code like
int temp;
fin>>temp;
But when I read the Cocoa documentation, I found NSFileHandle is suggested, and there is no method like I assumed, only one related method:
-…

Toney Sui
- 43
- 7
1
vote
2 answers
Does NSFileHandle -readDataOfLength: return autoreleased NSData?
When I call readDataOfLength: on an NSFileHandle instance, do I need to release the returned NSData? Currently I'm not, but I would like to get rid of this nagging doubt.

SSteve
- 10,550
- 5
- 46
- 72
1
vote
0 answers
How to ignore cache when repeatedly reading from disk
I am writing an app that contains a small benchmark for I/O operations.
For write operations, I am using a 'FileHandle' which works pretty well. I am testing my old USB stick and my calculation results in values of roughly 20MB/s which seems…

inexcitus
- 2,471
- 2
- 26
- 41
1
vote
0 answers
How can i output my program results to a file
This is the code I wrote. I am trying to output the results to a file. I used the open() but it does not work. Can someone please tell me what to do?
AP. result is the file in which I would like to copy the result to. However it does not copy. The…

Vanou
- 11
- 2
1
vote
1 answer
How does NSFileHandle offsetInFile work?
I am just wanting to know how offsetInFile works? and what is the difference between seekToFileOffSet. and code examples you know of would be helpfull as well :)

tinhead
- 385
- 2
- 10
- 29
1
vote
2 answers
Memory issue while converting big video file path to NSData. How to use InputStream/FileHandle to fix this issue?
I have a large sized video saved in my documents directory. I want to retrieve this video and remove it's first 5 bytes.
For large video files of above 300 MB using [NSData(contentsOf: videoURL)] causing Memory issue error.
I have gone through…

Sona
- 394
- 3
- 15
1
vote
0 answers
Character encoding issue for French characters in iOS
I have some French text in my application. I need to write that text to the document directory as an HTML file. When I write the file using NSFileHandler, the strings with special characters are not saved correctly.
Here is my code :
NSString *…

user1820190
- 11
- 4