• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: incompatible pointer type (was: Please help?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: incompatible pointer type (was: Please help?


  • Subject: Re: incompatible pointer type (was: Please help?
  • From: "Joshua D. Orr" <email@hidden>
  • Date: Fri, 22 Feb 2002 11:18:42 -0700

Another way to do it is to use the following method (with the encoding type set for what you getting, a plain text source will work with the this encoding):

[[NSString alloc] initWithData:theData encoding:NSASCIIStringEncoding];


It seems to work well for me. I use this to turn a donloaded NSData html file into a NSString...



Message: 5
Date: Fri, 22 Feb 2002 16:35:06 +0100
To: Albert Atkinson <email@hidden>
From: Andrea Perego <email@hidden>
Subject: incompatible pointer type (was: Please help?...
Cc: <email@hidden>

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.

  • Follow-Ups:
    • Re: incompatible pointer type (was: Please help?)
      • From: Andreas Monitzer <email@hidden>
  • Prev by Date: RE: variable arguments in ObjC
  • Next by Date: RE What to do? (I have a simple method for doing it)
  • Previous by thread: Re: Programming NSImageView
  • Next by thread: Re: incompatible pointer type (was: Please help?)
  • Index(es):
    • Date
    • Thread