On Dec 14, 2008, at 1:48 PM, Chris Espinosa wrote:
On Dec 13, 2008, at 10:57 PM, Donald Hall <email@hidden> wrote:
Hi all,
I am trying to use the NSString method `+stringWithContentsOfFile:encoding:error:'
The documentation clearly says this method is available in OS X 10.4 and later. but I get the following warnings:
/Users/dhall/Projects/Script Timer 2.6 copy/AppController.m:658: warning: `NSString' may not respond to `+stringWithContentsOfFile:encoding:error:'
/Users/dhall/Projects/Script Timer 2.6 copy/AppController.m:658: warning: cannot find method `+stringWithContentsOfFile:encoding:error:'; return type `id' assumed
I am using the MacOSX10.4u.sdk. Development machine is running 10.5.5
Why would I be getting these warnings? At least on the development machine the program is working correctly.
Don't you want usedEncoding: as the second parameter?
OK, back at home and no longer on my iPhone, I see both of these defined in NSString.h:
/* These use the specified encoding. If nil is returned, the optional error return indicates problem that was encountered (for instance, file system or encoding errors).
*/
- (id)initWithContentsOfURL:(NSURL *)url encoding:(NSStringEncoding)enc error:(NSError **)error;
- (id)initWithContentsOfFile:(NSString *)path encoding:(NSStringEncoding)enc error:(NSError **)error;
+ (id)stringWithContentsOfURL:(NSURL *)url encoding:(NSStringEncoding)enc error:(NSError **)error;
+ (id)stringWithContentsOfFile:(NSString *)path encoding:(NSStringEncoding)enc error:(NSError **)error;
/* These try to determine the encoding, and return the encoding which was used. Note that these methods might get "smarter" in subsequent releases of the system, and use additional techniques for recognizing encodings. If nil is returned, the optional error return indicates problem that was encountered (for instance, file system or encoding errors).
*/
- (id)initWithContentsOfURL:(NSURL *)url usedEncoding:(NSStringEncoding *)enc error:(NSError **)error;
- (id)initWithContentsOfFile:(NSString *)path usedEncoding:(NSStringEncoding *)enc error:(NSError **)error;
+ (id)stringWithContentsOfURL:(NSURL *)url usedEncoding:(NSStringEncoding *)enc error:(NSError **)error;
+ (id)stringWithContentsOfFile:(NSString *)path usedEncoding:(NSStringEncoding *)enc error:(NSError **)error;
Could you show the line with which you're trying to call stringWithContentsOfFile:, and perhaps the compiler invocation line for AppController.m?
Chris