tags:

views:

90

answers:

2

Is there anyway to do Files Handling in Objective-C? I am just trying to do simple read and write and can use 'c' but i am force to use Objective-C classes for that :@. I am looking into NSInputStream, but its going over my head. Is there any tutorial which explains how to use NSInputStream?

A: 

I find apple's guides short and to the point. http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Streams/Articles/ReadingInputStreams.html

Jesper Madsen
I am also reading this from last 30 min, but its not helping me :(
itsaboutcode
+1  A: 

If all you need to do is really simple I/O, you can just tell an object to initialize itself from, or write itself to, a filesystem path or URL. This works with several Foundation classes, including NSString, NSData, NSArray, and NSDictionary among others.

Try starting out by looking at the following two NSString methods:

- initWithContentsOfFile:encoding:error:

- writeToFile:atomically:encoding:error:

jlehr
Thanks man, it was really helpful.
itsaboutcode
You're welcome. I love the Foundation framework for this and a bazillion other reasons. :-)
jlehr