Re: Warning message using stringWithContentsOfFile:encoding:error:
Re: Warning message using stringWithContentsOfFile:encoding:error:
- Subject: Re: Warning message using stringWithContentsOfFile:encoding:error:
- From: Andy Lee <email@hidden>
- Date: Sun, 28 Oct 2012 12:13:13 -0400
(Sorry if the list gets this twice. I am going to strangle whoever thought it was a good idea to give me a me.com address as an alias for my mac.com address.)
On Oct 27, 2012, at 6:04 PM, Paul Johnson <email@hidden> wrote:
> I get a compiler warning message at the following line of code:
>
> NSString *text = [NSString stringWithContentsOfFile:fullPath encoding:
> NSUTF8StringEncoding error:&error];
>
> The warning message is:
>
> Class method '+stringWithContentsOfFile:encoding:Rf_error' not found
> (return type defaults to 'id')
Is this warning exactly what the compiler said, or did you manually copy it, possibly with a typo?
The reason I ask is that "stringWithContentsOfFile:encoding:Rf_error" is not a valid method name (it's missing a colon at the end). It seems odd that the compiler would think it was the message you were trying to send. If so, I wonder if there is a compiler bug.
I Googled "Rf_error" and there is a code base out there with an Rf_error.c file. Are you using that code base? I'm not sure how it could cause the problem -- I'm just wondering where the compiler could have come up with "Rf_error".
On Oct 27, 2012, at 7:21 PM, Paul Johnson <email@hidden> wrote:
> The warning message seems to be complaining about assigning to the type
> 'NString *' when type 'id' is expected, though.
No. You can freely assign any object pointer to id and vice versa. The warning says "method ... not found", and that's exactly what it means. The compiler is not aware of NSString (or any of its superclasses or protocols) having a method with that name, where for some reason "that name" is a screwy name rather than the one you intended.
On Oct 27, 2012, at 8:41 PM, Gary L. Wade <email@hidden> wrote:
> What you need to find is where "error" is being defined, not Rf_error.
This might help: type "error" right after the closing semicolon of the statement you showed us. Then Command-click on it and see where Xcode takes you.
--Andy
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden