• 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
Tracking changes to NSMutableString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Tracking changes to NSMutableString


  • Subject: Tracking changes to NSMutableString
  • From: Eric Wang <email@hidden>
  • Date: Sat, 16 Nov 2002 04:05:27 -0500

I have an class that declares an NSMutableString instance variable. I'd like
to be able to return the mutable string in an accessor method and have my
object track changes to the string in order to update other parts of my
application.


My class basically consists of the following:

@interface MyClass : NSObject
{
NSMutableString *mutableString;
}

@end

@implementation MyClass

- (NSMutableString *) mutableString
{
return mutableString;
}

@end


I'd like my object to track the following change:

- (void) changeText: (MyClass *) instanceOfMyClass
{
NSMutableString *text = [instanceOfMyClass mutableString];

[text replaceCharactersInRange: NSMakeRange(0, [text length])
withString: @"Some Text"];
}


The behavior I'm looking for is more or less the same thing
NSMutableAttributedString does when you call its -mutableString method. It
tracks changes to the returned mutable string so that it can keep its
attribute mappings up to date.

I initially thought to implement this using NSProxy, forwarding messages to
my object whenever its string changed, but after reading Apple's
documentation on distributed objects, I'm still not sure how to go about
doing this. Perhaps there is a another way. Does anyone know how
NSMutableAttributedString accomplishes this?

Thanks,
Eric Wang
_______________________________________________
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: Fullscreen transparent background
  • Next by Date: Re: setNeedsDisplayInRect: rect NO ????
  • Previous by thread: Re: Fullscreen transparent background
  • Next by thread: C callback functions in Cocoa
  • Index(es):
    • Date
    • Thread