开发者

what is this error message complaining about? and how to resolve it?

try to apply a patch and compile received warning message:

<some_file>: In function '-[XXXXX saveAndCreate:]':
<some_file>:262: warning: 'NSString' may not respond to '-stringByReplacingOccurrencesOfString:withString:'
<some_file>:262: warning: (Messages without a matching method signature
<some_file>:262: warning: will be assumed to return 'id' and accept
<some_file>:262: warning: '...' as arguments.)
distcc[6493] ERROR: compile (null) on localhost failed

which is complaining about this code,

[clientH开发者_运维技巧ost findAvailableIn:
    [clientHost defaultVMPath]
    baseName:
        [displayName stringByAppendingPathExtension:PL_BUNDLE_EXTENSION]
    nameFormat:[[displayName
                     stringByReplacingOccurrencesOfString:@"%"
                                               withString:@"%%"]
                     stringByAppendingString:@" %u.xxxx"]
    startIndex:2
    contextInfo:contextInfo];

and here is part of the compile command:

lin32/gcc-5363-1/bin/i686-apple-darwin8-gcc -mmacosx-version-min=10.4 -arch i386 -march=pentium-m -mtune=prescott -Werror -Wall -Wno-trigraphs -Wreturn-type -Wunused-variable -pipe -O2 -g3 -gfull -Wno-pointer-sign -x objective-c -fobjc-exceptions -fpascal-strings -fmessage-length=0 

googled the warning and tried the method here , but still got warning message alike.

i am ignorant in Mac development, spare me if this is something obvious (and i donnot know if the information provide above is surfficent, let me know what else needed to provide). thanx.

edit: 1) extend the code block. 2) correct the warning message.


The warning is referencing a different line the one you cited. The message you use is called stringByReplacingOccurrencesOfString:withString: which is fine on NSString. However the method replaceOccurrencesOfString:withString attempts to change the receiver. NSString is immutable and can therefore not be changed. If you want to use that method send it to a NSMutableString object.


Are you importing <Foundation/Foundation.h>? What is very surprising is that you would receive this warning, but no warning on -stringByAppendingPathExtension. Is this really the only warning you're receiving?

I recommend breaking up the code to create some temporary variables. You're doing so many nested method calls, it makes it very hard to be certain where your errors are. The compiler will optimize out most temporary variables, so there's no reason to avoid them when it makes the code clearer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜