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
1
vote
1 answer
Accessing Named Pipe for reading and writing
I am trying to create a simple tool that can create, write and read a named pipe. Here is the code.
int main(int argc, const char * argv[])
{
@autoreleasepool
{
//create pipe
system("rm /tmp/myPipe");
system("mkfifo…

jbrown94305
- 185
- 2
- 11
1
vote
1 answer
Difference between -fileHandleForWritingAtPath: and fileHandleForUpdatingAtPath:?
For me it sounds like the same thing. Updating a file implies to write to the file. Writing to a file is also an update for me. But I guess there's a subtle difference ;-)
Does anyone know?

Proud Member
- 40,078
- 47
- 146
- 231
1
vote
1 answer
NSFileHandle fileHandleForReadingFromURL can someone explain this to me please?
I am trying to make a customized input stream based off of the one by Dave DeLong here that also allows for reading data from a server via NSURL. So far, I have this approach, which works fine for local files:
@interface RJRStreamReader : NSObject…

Richard J. Ross III
- 55,009
- 24
- 135
- 201
1
vote
1 answer
How to use CFSwapInt32BigToHost , CFSwapInt16BigToHost effectively in Swift
I'm working on an app and trying to port an old Obj-C code to Swift. As its related to FileHandling and I've little to no experience on working on it, I'm bit confused on how to do it. That's why I need your help -
This is the method that I'm stuck…

Vineet
- 161
- 1
- 8
1
vote
2 answers
Append new string to txt file in swift 2
I used to do coding in java but now I want to move my app to iOS using swift 2.
So I want a method to append text in new line to an existing txt file in app documents.
I searched and tried so many methods but its all overwriting to new txt file
In…

Faris sy
- 61
- 1
- 5
1
vote
1 answer
Best way to send large files via TCP in Cocoa
I'm devising a protocol to be sent via TCP packets that can sometimes send large (video) files between iOS and OSX devices. I've got three questions:
1) What is the maximum size for each TCP packet for good performance? ie: Is it better to get…

Christopher Schardt
- 391
- 3
- 13
1
vote
1 answer
AVPlayer with Streaming videos or NSFileHandle
In my app I need to play multiple videos one after another. Currently, I am streaming the videos using AVPlayer but its seems very laggy, the videos freeze quite often. I'm wondering if downloading the files with NSFileHandle will provide a better…

Peter
- 1,053
- 13
- 29
1
vote
0 answers
iPhone OS 4.0: NSFileHandleDataAvailableNotification not providing callback at file-end
I'm a bit new to iPhone development, so be gentle! I'm supporting an app which loads a wav file from a URL file-stream, and plays it back through an AudioQueue.
We run a continual loop in another thread, and stop the Queue if we detect that it has…

Chowlett
- 45,935
- 20
- 116
- 150
1
vote
1 answer
How to make NSFilehandle to delete and write data concurrently in Objective c
I have written 2 methods:
WriteToLogFile
DeleteLogFile
and I am using NSFileHandle for this
My Code is written as:
- (void)WriteToLogFile:(NSString *)string {
dispatch_async(logQueue ,^ {
if (nil == fileHandle) {
// log file…

sulabh
- 249
- 5
- 22
1
vote
2 answers
How to write data in chunks into disk in ios
Hi in my app I am downloading a pdf file and that total size i am getting in chunks. Now after i get that data in chunks I am storing in NSData object and remaining chunks I am appending to the same object. while doing this app is getting crash with…

Naresh G
- 117
- 1
- 10
1
vote
0 answers
NSFileHandle writeData blocking risk
My application needs to write a short packet of data periodically to a group of TCP connections, each of which is encapsulated by an NSFileHandle. NSFileHandle offers asynchronous reading, but for writing, I think I have to use writeData (my…

David Lobron
- 1,039
- 2
- 12
- 21
1
vote
2 answers
How to download a wav file from the web to a location on iPhone using NSFileHandle and NSURLConnection?
I want to download a wav file from a web service, cache it on the iphone and playback it using AVAudioPlayer. Using NSFileHandle and NSURLConnection seems a viable solution when dealing with relatively large files. However, after running the app in…

saurb
- 685
- 1
- 13
- 24
1
vote
1 answer
NSFileHandle reading corrupt data from Video file
I'm using NSFileHandle to get the data of a video as its being recorded.
It works fine notification-wise and I'm getting notified using NSFileHandleDataAvailableNotification. The problem is the video file eventually doesn't work.
Everytime when…

Shai Mishali
- 9,224
- 4
- 56
- 83
1
vote
1 answer
read data of specific length from a specific position ios
I have the following code for reading a file in length of specific size:
int chunksize = 1024;
NSData* fileData = [[NSFileManager defaultManager] contentsAtPath:URL];
NSString* fileName = [[message.fileURL lastPathComponent]…

just ME
- 1,817
- 6
- 32
- 53
1
vote
1 answer
NSFileHandle fileHandleForWritingAtPath returns nil with valid path
found a few things on this issue but so far nothing has worked.
I'm trying to write to the end of a file using the following code:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Filename" ofType:@"txt"];
NSString *textToWrite =…

AndyW
- 985
- 3
- 10
- 21