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

Re: undoManagerForTextView:


  • Subject: Re: undoManagerForTextView:
  • From: James Bucanek <email@hidden>
  • Date: Thu, 22 Jun 2006 07:25:23 -0700

email@hidden wrote on Thursday, June 22, 2006:

> Hello all,
>
> I have two related questions about the
>-undoManagerForTextView: method in NSTextView :
>
>1) Why does it have an argument at all ? It looks redundant.
>If, say, you want to access the undo manager of myTextView,
>you would type
>
>   NSUndoManager* manager=[myTextView undoManagerForTextView: myTextView];
>
>  Wouldn´t it be more logical if it was a class method :
>
> +(NSUndoManager*) undoManagerForTextView: aTextView;
>
>or a method without argument :
>
> -(NSUndoManager*) undoManagerForTextView;

You need to read the documentation again carefully. undoManagerForTextView: is defined as an informal protocol on NSTextView's delegate -- not NSTextView itself. It is defined so that a delegate can provide an alternate undo manager for one or more text views. The parameter is required so that the delegate knows which NSTextView is being referenced.

As a general rule, NSObject class documentation is broken into three parts: The methods defined for the class, the messages sent to its delegate, and the constants used by the class. You need to pay careful attention to which section you're reading.

>2) I subclassed NSTextView and used undoManagerForTextView: on my subclass
>in my code.
>The project builds fine but crashes at runtime, and the console explains that
>my subclass does not recognize the selector @(undoManagerForTextView:). Why ?
>If I read the NSTextView.h file correctly, the method
>undoManagerForTextView is protected, so it should also work with
>a subclass.

That's because NSTextView doesn't respond to undoManagerForTextView:.

--
James Bucanek
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >undoManagerForTextView: (From: email@hidden)

  • Prev by Date: Re: Writing GPS Exif tags
  • Next by Date: Re: Imbedding unicode in strings
  • Previous by thread: undoManagerForTextView:
  • Next by thread: Cocoa Application build fails gives unknown symbol '___dso_handle'
  • Index(es):
    • Date
    • Thread