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

Re: NSData


  • Subject: Re: NSData
  • From: Mel Walker <email@hidden>
  • Date: Fri, 13 Dec 2002 11:15:27 -0700

On Friday, December 13, 2002, at 08:32 AM, matt neuburg <email@hidden> wrote:
- (void)forwardInvocation:(NSInvocation *)invocation {
if ([self->theString respondsToSelector:[invocation selector]])
[invocation invokeWithTarget:self->theString];
else
[self doesNotRecognizeSelector:[invocation selector]];
}

- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector {
if ([theString respondsToSelector: aSelector])
return [theString methodSignatureForSelector:aSelector];
return [super methodSignatureForSelector:aSelector];
}

@end

And here is some code to test it with:
[...]
// this fails, correctly - neither MyString nor NSString can respond
NSRunAlertPanel(@"Test3", [s junk], nil, nil, nil);
[s release];

Since I'm controlling the whole "inheritance" process here with forwardInvocation: and methodSignatureForSelector:, is there a way I can get bad selectors to fail silently? For example, in the [s junk] call, can I just print out "bad selector:'junk'" and keep running with the application?

Not that I have any reason at all for doing this in any application I'm writing at the moment; it just seems like something cool I'd like to know. :-)

--
Mel Walker <email@hidden>
Software Engineer
_______________________________________________
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.

  • Follow-Ups:
    • Re: NSData
      • From: Mike Shields <email@hidden>
  • Prev by Date: NSCopyBits tain't clear
  • Next by Date: semi-transparent NSScrollView/NSTextView
  • Previous by thread: Re: NSData
  • Next by thread: Re: NSData
  • Index(es):
    • Date
    • Thread