Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mdeh

macrumors 6502
Original poster
Jan 3, 2009
345
2
Hi all,
May I ask for some help with a conceptual understanding of an issue that I have not been able to clearly discern from the documents.

It concerns the role of an NSFileHandle object in relation to pipes, in for example, running a task from within a cocoa ap.

Right now, I understand a pipe ( conceptually) to be mechanism whereby the output of one unix operation/command is directed to the input of another, and vice-versa (understanding that pipes are unidirectional). So, the example that was used to illustrate this, was cat|wc ( for a pipe *from* cat *to* wc).

In the actual construction of an operation to perform this, the role of NSTask makes sense, the role of NSPipe does so too, but I cannot conceptually place the role of NSFileHandle. Could someone give a nice concise concept to this for me and then, what does it **actually** do?

Thanks in advance.
 

Sydde

macrumors 68030
Aug 17, 2009
2,552
7,050
IOKWARDI
Read the documentation again. Does NSPipe itself respond to any methods for transfering actual data?
 

Sayer

macrumors 6502a
Jan 4, 2002
981
0
Austin, TX
NSFileHandle is a reference to where data will go; UNIX is built around the concept of "files" as an abstract bit container. Devices can be accessed as a "file" and written to/read from.

There are several standard system-defined file handles for things like the console, standardized so every app can write text messages to it for viewing in a console viewing app (reading from the file handle).
 

mdeh

macrumors 6502
Original poster
Jan 3, 2009
345
2
NSFileHandle is a reference to where data will go; UNIX is built around the concept of "files" as an abstract bit container. Devices can be accessed as a "file" and written to/read from.

There are several standard system-defined file handles for things like the console, standardized so every app can write text messages to it for viewing in a console viewing app (reading from the file handle).


Firstly, thanks Sayer. So, if I understand you correctly, by defining a FileHandle, I am "redirecting" the output/input to something that is useful to me ...the programmer. So, if I wish to write a string to NSLog, I can "direct" the output of the pipe to an NSData Object that I control, and then read it and display it just like any other (data) object.

Thanks again for your input.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.