Skip navigation.
 
mlRe: File Input
FROM : Shawn Erickson
DATE : Mon Nov 29 19:03:31 2004

On Nov 29, 2004, at 8:51 AM, Danielle MacNevin wrote:

> Hey there,
>
> I've been looking into file input with Objective c in cocoa, but I 
> haven't gotten very far.  I've read over 
> http://developer.apple.com/documentation/Cocoa/Conceptual/TextIO/
> Tasks/UsingTextIO.html and 
> http://developer.apple.com/documentation/Cocoa/Conceptual/Streams/
> Articles/ReadingInputStreams.html a few times but I was looking for 
> some more documentation and I wasn't coming across much on my 
> searches.
>
> I was wondering if someone knew of a site that had some good 
> documentation on reading in files in objective c, or if anyone could 
> provide some simple sample code.
>
> Thanks so much
> Danielle


This isn't really a question specific to the Objective-C language but 
to using the Cocoa framework. I suggest sending such questions to the 
Apple list dedicated to such questions/discussions.

<http://www.lists.apple.com/mailman/listinfo/cocoa-dev/>

[NOTE: I am copying the cocoa-dev list. Please consider moving any 
further discussion to that list.]

It isn't clear on what type of file access you are looking for but...

NSFileHandle[1], NSFileManager[2] and friends (consider even NSURL[3] 
and friends) are the interface that Cocoa provides for file access. See 
the following topic for more information...

<http://developer.apple.com/documentation/Cocoa/Conceptual/
LowLevelFileMgmt/index.html
>

Also note that classes like NSData, NSImage, etc. all provide method to 
read in or write out their data to files.

Additionally you can easily use standard C / POSIX / BSD file 
operations as well as CoreFoundation functions (Cocoa uses aspect of 
CoreFoundation,  POSIX and BSD APIs to provide NSFileHandle, etc.).

For example (which you may have already found via Cocoa streams 
conceptual documentation)...

<http://developer.apple.com/documentation/CoreFoundation/Reference/
CFWriteStreamRef/Reference/FunctionGroupIndex.html
>

As to example code if you click on the Apple reference library link, 
then on Cocoa, then File Management, and select sample code from the 
popup under "display" you will get the following page.

<http://developer.apple.com/samplecode/Cocoa/idxFileManagement-
date.html#doclist
>

-Shawn

[1] 
<http://developer.apple.com/documentation/Cocoa/Reference/Foundation/
ObjC_classic/Classes/NSFileHandle.html#//apple_ref/occ/cl/NSFileHandle
>
[2] 
<http://developer.apple.com/documentation/Cocoa/Reference/Foundation/
ObjC_classic/Classes/NSFileManager.html#//apple_ref/occ/cl/
NSFileManager
>
[3] 
<http://developer.apple.com/documentation/Cocoa/Reference/Foundation/
ObjC_classic/Classes/NSURL.html#//apple_ref/occ/cl/NSURL
>

Related mailsAuthorDate
mlFile Input Danielle MacNevin Nov 29, 17:53
mlRe: File Input Shawn Erickson Nov 29, 19:03
mlRe: File Input John C. Randolph Dec 2, 01:44