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

Re: undo prepareWithInvocationTarget KVC


  • Subject: Re: undo prepareWithInvocationTarget KVC
  • From: Steven Spencer <email@hidden>
  • Date: Sun, 3 Jul 2005 14:38:29 +0100

I've found a solution :

        myObj *mx = [myArray objectAtIndex:0];

SEL theSelector = @selector(setValue:forKeyPath:);
NSMethodSignature *sig = [mx methodSignatureForSelector:theSelector];
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:sig];
[inv setSelector:theSelector];
[inv setTarget:mx];


        NSString *h = @"Hello";
        NSString *t = @"target";

        //Note: indices 0 and 1 are reserved for self and _cmd
        [inv setArgument:&h atIndex:2];
        [inv setArgument:&t atIndex:3];

        [[self undoManager] prepareWithInvocationTarget:mx];
        [[self undoManager] forwardInvocation:inv];

  - Steve Spencer


On 3 Jul 2005, at 01:18, Steven Spencer wrote:

Hello,

In my project, the following line of code works :

[[[self undoManager] prepareWithInvocationTarget:[myArray objectAtIndex:0]] setTarget:@"Hello"];

   myArray is an NSArray containing instances of class myObj.
   Class myObj has two methods :

   - (void)setTarget:(NSString *)aString;
   - (NSString *)target;

   myArray is bound to a tableview column.


When I replace the line with :

[[[self undoManager] prepareWithInvocationTarget:[myArray objectAtIndex:0]] setValue:@"Hello" forKey:@"target"];

the following errors can occur :

sigsev,
sigbus,
[<NSCFString 0x33d950> valueForUndefinedKey:]: this class is not key value coding-compliant for the key target.


Does anyone know why it's looking for the key "target" in a string instead of a myObj instance ?


The error occurs after the prepareWithInvocationTarget code has run, when a new row is selected in the tableview.


Thanks for any insight.

  - Steve Spencer


_______________________________________________ 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: 
 >undo prepareWithInvocationTarget KVC (From: Steven Spencer <email@hidden>)

  • Prev by Date: Using my framework source code for GUI application ?
  • Next by Date: Re: Thwarting classdump, etc.
  • Previous by thread: undo prepareWithInvocationTarget KVC
  • Next by thread: Core Data & Bindings & dynamic contents - newbie question
  • Index(es):
    • Date
    • Thread