Re: XCode const warnings
Re: XCode const warnings
- Subject: Re: XCode const warnings
- From: Clark Cox <email@hidden>
- Date: Fri, 13 Feb 2004 11:48:14 -0500
On 2004/02/13, at 10:57, Darrin Cardani wrote:
>
I have a project I've been building with Project Builder. I recently
>
moved the project to XCode and am now getting some warnings I wasn't
>
getting with PB. For example, I'm calling NSMutableString's
>
replaceOccurrencesOfString:withString:options:range method. The
>
"withString" parameter I'm passing is declared as:
>
>
const NSString* myString = @"blah";
>
>
So I'm getting the warning:
>
>
invalid conversion from `const NSString*' to `NSString*'
>
>
I guess the compiler's right, but since it requires an NSString
>
instead of an NSMutableString, it shouldn't make any difference,
>
should it? I can cast away the const-ness, but I just want to make
>
sure that's not going to cause any problems. Is it? I have a couple
>
dozen of these warnings. Should I be avoiding using NSStrings as
>
constants, and instead just make them regular globals?
>
>
I also get a similar problem when putting these constant strings into
>
NSDictionaries. I get:
>
>
invalid conversion from `const NSString*' to `obc_object*'.
>
>
I just want to make sure whatever I do is safe. Any suggestions would
>
be appreciated.
Use "NSString *const myString" instead of "const NSString *myString".
--
Clark S. Cox III
email@hidden
http://homepage.mac.com/clarkcox3/
http://homepage.mac.com/clarkcox3/blog/B1196589870/index.html
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.