• 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
Extending NSTextStorage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Extending NSTextStorage


  • Subject: Extending NSTextStorage
  • From: Дмитрий Николаев <email@hidden>
  • Date: Wed, 11 May 2011 11:12:55 +0400

Hello!

According to documentation, I try to subclass NSTextStorage and use it in text view:

/*
NSTextStorage is a semi-abstract subclass of NSMutableAttributedString. It implements change management (beginEditing/endEditing), verification of attributes, delegate handling, and layout management notification. The one aspect it does not implement is the actual attributed string storage --- this is left up to the subclassers, which need to override the two NSMutableAttributedString primitives:

  - (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)str;
  - (void)setAttributes:(NSDictionary *)attrs range:(NSRange)range;

*/

So I try to use delegate, to handle all needed events with same functionality:

------------------------ code --------------------------

@implementation MyTextStorage

- (id) init {
	self = [super init];

	if (self != nil) {
		storage = [[NSMutableAttributedString alloc] init];
	}

	return self;
}

- (void) dealloc {
	[storage release];
	[super dealloc];
}

- (NSString *) string {
	return [storage string];
}

- (void) replaceCharactersInRange:(NSRange)range withString:(NSString *)str {
	[storage replaceCharactersInRange:range withString:str];
}

- (void)setAttributes:(NSDictionary *)attrs range:(NSRange)range {
	[storage setAttributes:attrs range:range];
}


@end

------------------------ /code --------------------------

It is no matter what I'm use as delegate: NSTextStorage or NSMutableAttributedString, The result is the same:

---------------- log -------------------

An uncaught exception was raised
*** NSRunStorage, _NSBlockNumberForIndex(): index (18446744073709551615) beyond array bounds (0)
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** NSRunStorage, _NSBlockNumberForIndex(): index (18446744073709551615) beyond array bounds (0)'

---------------- /log -------------------

What I need to do to extend this class ?


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Extending NSTextStorage
      • From: Martin Wierschin <email@hidden>
  • Prev by Date: Re: What state does an iOS app retain after being quit that causes it to crash on relaunch?
  • Next by Date: Re: PDFDocument and CGPDFDocument
  • Previous by thread: Re: What state does an iOS app retain after being quit that causes it to crash on relaunch?
  • Next by thread: Re: Extending NSTextStorage
  • Index(es):
    • Date
    • Thread