• 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: Please help?...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Please help?...


  • Subject: Re: Please help?...
  • From: Albert Atkinson <email@hidden>
  • Date: Sat, 23 Feb 2002 12:36:45 -0500

So, that was why it was not working. I was trying to execute a script
that looked like:

[textField replaceCharactersInRange:withRTF:fileContents]

However, the script you gave me does not seem to work. Here is what I
have total:

- (void)windowControllerDidLoadNib:(NSWindowController *) aController;
{
[super windowControllerDidLoadNib:aController];
if (fileContents)
{
// this line would be different in your implementation...
// say, replaceCharactersInRange:withRTF:
[textView replaceCharactersInRange:NSMakeRange(0,0)
withRTF:fileContents];
[fileContents release];
fileContents = nil;
}
}

But it gives me this error when trying to open an RTF file:

2002-02-23 11:51:14.249 PowerText[4025] *** Assertion failure in
-[Document loadDataRepresentation:ofType:], Document.m:31
2002-02-23 11:51:14.253 PowerText[4025] Unknown type

Can you figure our what is going wrong?

Sorry about these stupid questions.

Albert

On Saturday, February 23, 2002, at 01:50 AM, Scott Anguish wrote:

> On Friday, February 22, 2002, at 05:36 PM, Albert Atkinson wrote:
>
>> Sorry, I am extremely new to this and still am lost. You are meaning
>> that the line:
>>
>> [theTextView setString:fileContents];
>>
>> Would be different in my implementation?
>
> Yep.
>
>> Could you give me the code that I would use for opening RTF files? I
>> can not figure this out for anything and am getting myself confused.
>
> it's right there
>
> [whateveryourtextviewis replaceCharactersInRange:NSMakeRange(0,0)
> withRTF:fileContents]
>
>
>
>
>>
>> Thanks!
>>
>> Albert
>>
>> On Friday, February 22, 2002, at 11:58 AM, Scott Anguish wrote:
>>
>>> right.. as I said, in the email, you'll need to adjust that code to
>>> use a slightly different call than setString:
>>>
>>> - (void)windowControllerDidLoadNib:(NSWindowController *) aController;
>>> {
>>> [super windowControllerDidLoadNib:aController];
>>> if (fileContents)
>>> {
>>> // this line would be different in your implementation...
>>> // say, replaceCharactersInRange:withRTF:
>>> [theTextView setString:fileContents];
>>> [fileContents release];
>>> fileContents = nil;
>>> }
>>> }
>>>
>>> On Friday, February 22, 2002, at 06:49 AM, Albert Atkinson wrote:
>>>
>>>> Hmm,
>>>>
>>>> I just added the following windowControllerDidLoadNib: code:
>>>>
>>>> - (void)windowControllerDidLoadNib:(NSWindowController *)
>>>> aController;
>>>> {
>>>> [super windowControllerDidLoadNib:aController];
>>>> if (fileContents)
>>>> {
>>>> [textView setString:fileContents];
>>>> [fileContents release];
>>>> fileContents = nil;
>>>> }
>>>> }
>>>>
>>>> Now when I build my app it gives me a warning:
>>>>
>>>> warning: passing arg 1 of 'setString:' from incompatible pointer
>>>> type
>>>>
>>>> It builds it and runs it and when I choose the RTF file it gives me
>>>> this error:
>>>>
>>>> 2002-02-22 06:44:49.421 PowerText[3493] *** Assertion failure in
>>>> -[Document loadDataRepresentation:ofType:], Document.m:31
>>>> 2002-02-22 06:44:49.448 PowerText[3493] Unknown type
>>>>
>>>> Also, this did not happen before I added the code but if I close the
>>>> last window and switch to a different application and then switch
>>>> back it will crash and say:
>>>>
>>>> PowerText.app has exited due to signal 10 (SIGBUS).
>>>>
>>>> This also happens if I close the last document window and try to
>>>> open something again.
>>>>
>>>> Any suggestions?
>>>>
>>>> Thanks!
>>>>
>>>> Albert
>>>>
>>>> On Friday, February 22, 2002, at 01:49 AM, Scott Anguish wrote:
>>>>
>>>>> are you sure this isn't working?
>>>>>
>>>>> part of the problem is that you're not actually doing anything with
>>>>> the fileContents by the looks of things.. that's something that is
>>>>> usually handled in the windowControllerDidLoadNib:.. and you're not
>>>>> calling super there either.. which may be an issue at some point...)
>>>>>
>>>>> so nothing is going to happen in your UI.. you just have a variable
>>>>> (fileContents) set with the data..
>>>>>
>>>>> - (void)windowControllerDidLoadNib:(NSWindowController *)
>>>>> aController;
>>>>> {
>>>>> [super windowControllerDidLoadNib:aController];
>>>>> if (fileContents)
>>>>> {
>>>>> [theTextView setString:fileContents];
>>>>> [fileContents release];
>>>>> fileContents = nil;
>>>>> }
>>>>> }
>>>>>
>>>>>
>>>>> also, you really don't need to copyWithZone:.. you could just
>>>>> retain the data if you wanted to (and Zones are sort of unnecessary
>>>>> for most apps according to general scuttlebutt)
>>>>>
>>>>>
>>>>> On Thursday, February 21, 2002, at 09:23 PM, Albert Atkinson wrote:
>>>>>
>>>>>> Hello!
>>>>>>
>>>>>> I am trying to implement a simple saving and loading of rtf files
>>>>>> in my
>>>>>> app. I have the following code in my "Document.m" file:
>>>>>>
>>>>>> #import "Document.h"
>>>>>>
>>>>>> @implementation Document
>>>>>>
>>>>>> - (NSString *)windowNibName
>>>>>> {
>>>>>> return @"Document";
>>>>>> }
>>>>>>
>>>>>> - (void)windowControllerDidLoadNib:(NSWindowController *)
>>>>>> aController
>>>>>> {
>>>>>>
>>>>>> }
>>>>>>
>>>>>>
>>>>>> - (NSData *)dataRepresentationOfType:(NSString *)aType {
>>>>>> NSAssert([aType isEqualToString:@"rtf"], @"Unknown type");
>>>>>> return [textView RTFFromRange:NSMakeRange(0, [[textView
>>>>>> textStorage]
>>>>>> length])];
>>>>>> }
>>>>>>
>>>>>>
>>>>>> - (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString
>>>>>> *)aType {
>>>>>> NSAssert([aType isEqualToString:@"rtf"], @"Unknown type");
>>>>>> fileContents = [data copyWithZone:[self zone]];
>>>>>> return YES;
>>>>>> }
>>>>>>
>>>>>> @end
>>>>>>
>>>>>> I must be doing something wrong because this does not work. Any
>>>>>> suggestions?
>>>>>>
>>>>>> Thanks!
>>>>>>
>>>>>> Albert
>>>>>> _______________________________________________
>>>>>> 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.
>>>>> _______________________________________________
>>>>> 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.
_______________________________________________
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.

  • Prev by Date: Re: NSPopupButton and fonts
  • Next by Date: Re: number formatting
  • Previous by thread: Re: +poseAsClass and instance variables
  • Next by thread: Managing non-compiled files in project builder
  • Index(es):
    • Date
    • Thread