Re: Question about a warning in code...
Re: Question about a warning in code...
- Subject: Re: Question about a warning in code...
- From: Ondra Cada <email@hidden>
- Date: Mon, 10 Sep 2001 21:12:23 +0200
Ed,
>
>>>>> Ed Silva (ES) wrote at Mon, 10 Sep 2001 11:52:12 -0700:
ES> script_buf = [tmp_buf substringToIndex:range.location]; // <== This is
ES> where the warning occurs...
ES>
ES> Why am I getting this warning when tmp_buf and script_buf are both
ES> NSMutableStrings?
Since substringToIndex: returns an NSString, not an NSMutableString.
ES> The code works fine
Just happens to, since you don't change the result. Try this:
7 /tmp\> cat qq.m
#import <Foundation/Foundation.h>
void main() {
id p=[NSAutoreleasePool new];
NSMutableString *s=[NSMutableString stringWithString:@"qq__qq"],*sub=[s
substringToIndex:2];
NSLog(@"so far so good");
[sub appendString:@"Oops this would crash"];
NSLog(@"Would not be reached");
[p release];
}
8 /tmp\> cc -framework Foundation qq.m && ./a.out
qq.m: In function `main':
qq.m:4: warning: initialization from incompatible pointer type
Sep 10 21:09:24 a.out[785] so far so good
Sep 10 21:09:24 a.out[785] *** -[NSInlineCString appendString:]: selector
not recognized
Sep 10 21:09:24 a.out[785] *** Uncaught exception:
<NSInvalidArgumentException> *** -[NSInlineCString appendString:]: selector
not recognized
stack: 0x4257d568 0x42586704 0x42583cdc 0x42581ae0 0x42581a48 0x42584e2c
0x425255cc 0x413c4724 0x1e64 0x1cd4 0x1b94
9 /tmp\>
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc