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
0
votes
1 answer
Is there any way to emulate user's input in XCTest function?
I have method which expects user's input
@implementation TeamFormation
- (void)run {
NSFileHandle *kbd = [NSFileHandle fileHandleWithStandardInput];
NSData *inputData = [kbd availableData];
NSString *option = [[[NSString alloc]…

Ihar Katkavets
- 1,510
- 14
- 25
0
votes
1 answer
What's the most efficient way / strategy for persistent (not in memory) in app logging of text?
I have a navigation and location tracking app. While a user is tracking his trip, coordinates, speed, timestamp (and a few more) are logged with each coordinate that comes in. I don't want to store this in memory as that would make the app memory…

guido
- 2,792
- 1
- 21
- 40
0
votes
0 answers
NSFilSize is only returns 192 for any file path
i tried with attributesOfItemAtPath of NSFileManager to get file size of previously saved video. it's only returning 192 always.
NSDictionary *assetDIct = [[NSFileManager defaultManager] attributesOfItemAtPath:[assetUrl path]…

Code cracker
- 3,105
- 6
- 37
- 67
0
votes
1 answer
HTTP server works in Cocoa application but not test case -- run loop issue?
I'm trying to add a GHUnit test case to this SimpleHTTPServer example. The example include a Cocoa application that works fine for me. But I can't duplicate the behavior in a test case.
Here is the test class:
#import
#import…

jlstrecker
- 4,953
- 3
- 46
- 60
0
votes
0 answers
What is the best way to store large file data into Coredata in iOS
I am trying to store 30k users details in to core data. To achieve this I search and came up with a solution to have all the data in a file in CSV format.
I am able to download and read CSV file to using following code:
func readCsvFile () {
if…

Sagar In
- 591
- 1
- 4
- 8
0
votes
0 answers
App crash when I my app in background and locked
I use the method bellow:
[filehandler writeData:[NSData dataWithBytesNoCopy:bytes length:size freeWhenDone:NO]];
filehandler is NSFileHandle, when my phone locked the value after some seconds arrive Null and my app crash.
Here is the crash …

Steven
- 762
- 1
- 10
- 27
0
votes
1 answer
NSFileHandle behaving strangely when run without debugger - some NSRunLoop issue?
I'm writing a plugin for Adobe Premiere on Mac, which opens an external application and then uses NSPipe and NSFileHandle to read the standard output from the external application. I know the recommended ways to do this involve either using…

Thomas
- 485
- 4
- 15
0
votes
1 answer
SIGABRT: -[NSConcreteFileHandle seekToEndOfFile]: No such file or directory
So I am writing accelerometer values to a csv file. Sometimes it works and sometimes it doesn't. Typically when the accelerometer is on for over 5 seconds it crashes and I get the error.
Here is the code:
int recordbuttonstatus=0;
int…

Zen
- 1
- 3
0
votes
2 answers
Couple of questions on NSFileHandle, Obj-C
I'm working now on Obj-C with files, my application shall read some huge text files (e.g. 5 MB) that have character encoding of UTF16..
The first problem is how do I detect the file size that I'm going to read from ?
The second problem is when I…

ObjProg
- 429
- 1
- 7
- 19
0
votes
1 answer
Must I close the File Handle when doing this?
Example:
NSData *fileData = [fileHandle readDataToEndOfFile];
Am I responsible for closing that file handle? (I think I'm not...but just 99.95% sure!)

Proud Member
- 40,078
- 47
- 146
- 231
0
votes
1 answer
Does NSFileHandle create the sockets for me?
Does NSFileHandle create the sockets for me? Or must I create them myself and then setup an NSFileHandle to use that socket?

Proud Member
- 40,078
- 47
- 146
- 231
0
votes
1 answer
Locating custom files in iOS app
I need to place some files in my iOS app initially and with app run copy them to Documents.
I placed them to main bundle, but I can not move them. Then I am trying to do it I have an error.
I find out that those files are not writable.
So how can I…

sffsf
- 55
- 5
0
votes
0 answers
how to handle NSFileHandle writeData method exception?
To log any message on file I am using writeData method of NSFileHandle. Sometimes this method throws an exception but I can not handle it because code is written in swift.
Is there any work around ?
I have tried this :
I have tried this :…

Aashish Nagar
- 1,207
- 1
- 14
- 30
0
votes
2 answers
Writing large and frequent data to a file in iOS?
I would like to save data to a file every second. The data records is simple, just a date and number, and would like to append to the file. This can last the whole day, so the file can end up being big.
I do not want to block the main thread, nor…

TruMan1
- 33,665
- 59
- 184
- 335
0
votes
2 answers
NSFileHandle updateatPath how can i update file instead of overwriting?
I am trying to create a file and update the file by adding a string to the end each time i hit save button. However, everytime i hit save it creates a new file (overwrites) with the latest string. My code is below, how can i fix it? please…

Gigi
- 1