parkimedes
Registered
Hi, I'm trying to do what seems like a very basic thing, but for some reason i can't figure it out. I've searched the web far and wide for a simple tutorial or example, and the best I could find was this:
NSString *pathToFile = [@"~/Desktop/smallTextFile.txt" stringByExpandingTildeInPath];
NSString *contentsOfFile = [NSString stringWithContentsOfFileathToFile];
printf("Contents of file: %s", contentsOfFile);
It sort of works, because if I move the file, the printf is "NULL" rather than "\240{\246t", but besides that difference, I get:
2006-10-22 15:48:51.597 NetFlix_01[3416] *** _NSAutoreleaseNoPool(): Object 0x308340 of class NSCFString autoreleased with no pool in place - just leaking
Contents of file: \240{\246t
The documentation on how to setup the Autoreleasepool is more confusing than helpful, and its VERY long. Does anyone know a quick answer to the question? how do I load text from a file into a string??
http://developer.apple.com/documentation/Cocoa/Conceptual/TextIO/TextIO.pdf
This link sounds promising, it explains with example code how to create and object and a method to do it, but it doesnt show how to call it. For example, where do I enter the file name? and what line brings the text into a string that I can use?
thanks,
-Parker
NSString *pathToFile = [@"~/Desktop/smallTextFile.txt" stringByExpandingTildeInPath];
NSString *contentsOfFile = [NSString stringWithContentsOfFileathToFile];
printf("Contents of file: %s", contentsOfFile);
It sort of works, because if I move the file, the printf is "NULL" rather than "\240{\246t", but besides that difference, I get:
2006-10-22 15:48:51.597 NetFlix_01[3416] *** _NSAutoreleaseNoPool(): Object 0x308340 of class NSCFString autoreleased with no pool in place - just leaking
Contents of file: \240{\246t
The documentation on how to setup the Autoreleasepool is more confusing than helpful, and its VERY long. Does anyone know a quick answer to the question? how do I load text from a file into a string??
http://developer.apple.com/documentation/Cocoa/Conceptual/TextIO/TextIO.pdf
This link sounds promising, it explains with example code how to create and object and a method to do it, but it doesnt show how to call it. For example, where do I enter the file name? and what line brings the text into a string that I can use?
thanks,
-Parker