Re: Preserving undo actions on deleted targets
Re: Preserving undo actions on deleted targets
- Subject: Re: Preserving undo actions on deleted targets
- From: Jerry Krinock <email@hidden>
- Date: Thu, 30 Jan 2014 21:13:41 -0800
On 2014 Jan 30, at 18:15, Graham Cox <email@hidden> wrote:
> I believe this usage is safe (for now), but certainly if a cleaner solution can be found that would be great,
Yesterday before I convinced myself that this was a non-issue, I tried the following code:
+ (void)load {
SEL aSEL = NSSelectorFromString(@"_processEndOfEventNotification:") ;
class_addMethod(self, aSEL, (IMP) doNothingIMP, "@@:@");
}
void doNothingIMP(id self, SEL _cmd) {
NSLog(@"Nothing doing!");
}
I tested it twice (saving a document), and it worked. That is, it logged "Nothing doing!” (3 times for each save) and raised no exceptions.
Note that I’m referencing _processEndOfEventNotification: as a string instead of @selector(). I agree with Quincey’s implication that a string seems less likely to raise App Store Hackles than a @selector(), but truly we’re all just guessing.
On 2014 Jan 30, at 11:20, Kyle Sluder <email@hidden> wrote:
> we've been rejected for merely *referencing* verboten selectors
What do you mean by that, Kyle? In a string? @selector()?
Y’all know that one could go further and obfuscate the string @"_processEndOfEventNotification:”, by breaking it up into several pieces, reversing it, etc., and ultimately reconstructing it into a mutable string. You have to be tricky enough to outwit the compiler, which will optimize out anything which is too boneheaded. But it can be done.
Again, in my opinion, none of this is necessary because either the string or the SEL is OK, as is Graham's original code. But I appreciate that preventing the issue with trickery is way better than spending hours to “win” a legal battle.
_______________________________________________
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