incompatible pointer type (was: Please help?...
incompatible pointer type (was: Please help?...
- Subject: incompatible pointer type (was: Please help?...
- From: Andrea Perego <email@hidden>
- Date: Fri, 22 Feb 2002 16:35:06 +0100
Dear Albert
Whenever the error message
passing arg n of 'someMethod:' from incompatible pointer type
appears, you have passed a wrong object reference as the nth
argument of 'someMethod'.
In your case, you are sending NSText's instance method message
- (void)setString:(NSString *)string;
to your NSTextView (a subclass of NSText) with 'fileContents' as arg.
From your snippet the type associated with 'fileContents' is not evident;
I'd guess it's NSData*, while you should pass a NSSTring* object or a subclass
thereof.
I've been struggling with this matter just a week ago and my present
solution to extract a NS[Attributed]String from a document file is
theText=[[NSMutableAttributedString alloc]
initWithPath:fileName documentAttributes:&formatDict];
used within
- (BOOL)readFromFile:(NSString *)fileName ofType:(NSString *)docType
This solution seem to work well but, as a disclaimer, consider that
I'm a newbie and found it just by trials and errors.
BTW, I'd like to tell a funny thing that happened during my
experiments: at some point of the process I was trying:
- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType{
...........
theText=[NSString stringWithCharacters:[data bytes] length:[data length]];
...........
}
using a plain C source text as document-source. When my text window
was displayed, I remained half a minute staring at the monitor like
petrified: a nice sequence of *Chinese ideograms* was shown in my
view! ;-O
The nice thing of Cocoa is that, without a line of code added by
myself, I was able to print the window and save it for my memorabilia
collection!
Original snippet
At 6:15 AM -0800 2/22/02, email@hidden wrote:
- (void)windowControllerDidLoadNib:(NSWindowController *) aController;
{
[super windowControllerDidLoadNib:aController];
if (fileContents)
{
[textView setString:fileContents];
[fileContents release];
fileContents = nil;
}
}
_______________________________________________
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.