• 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: [BUG] NSSelectorFromString Sometimes Lies
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [BUG] NSSelectorFromString Sometimes Lies


  • Subject: Re: [BUG] NSSelectorFromString Sometimes Lies
  • From: Nat! <email@hidden>
  • Date: Sun, 18 May 2003 22:12:39 +0200

Though I am always a sucker for a juicy bug (especially if I didn't write them) I can't reproduce this:

#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>


void test( NSString *selName)
{
NSString *name1, *name2;
SEL sel1, sel2;

sel1 = NSSelectorFromString( selName);
name1 = NSStringFromSelector( sel1);
sel2 = NSSelectorFromString( name1);
name2 = NSStringFromSelector( sel2);

NSLog( @"%@(%lx) : %s(%lx) %@ -> %s(%lx) %@", selName, selName, sel1, sel1, name1, sel2, sel2, name2);
}


int main (int argc, const char *argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

test( @"keyEventWithType:");
test( @"ha_i_ain't_no_selector:");

[pool release];
return 0;
}



> Running 'NSSelectorFromString'...
2003-05-18 22:11:24.774 NSSelectorFromString[924] keyEventWithType:(400c) : keyEventWithType:(7fe40) keyEventWithType: -> keyEventWithType:(7fe40) keyEventWithType:
2003-05-18 22:11:24.791 NSSelectorFromString[924] ha_i_ain't_no_selector:(4018) : ha_i_ain't_no_selector:(822e0) ha_i_ain't_no_selector: -> ha_i_ain't_no_selector:(822e0) ha_i_ain't_no_selector:

> Finished running 'NSSelectorFromString'.

If one iterates through the metaclass of NSEvent, one will get 0x906bf8b8 as
the selector for the class method keyEventWithType:...

I suspect that this routine isn't doing what you think it should be doing.

I also suspect that the routine NSStringFromSelector does little else than return( [NSString stringWithCString:(char *) sel]). The NSSelectorFromString seems to create a selector, when none previously existed.

Maybe post a little more of the source, to see where the problem lies or how to reproduce it.

Ciao
Nat!

Jedenfalls sind zehn Fehlstarts hintereinander [E. Fuchs]
ein sehr interessanter Beweis
fuer unsere Theorie
von der natuerlichen Ueberlegenheit des Dezimalsystems
_______________________________________________
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.

References: 
 >[BUG] NSSelectorFromString Sometimes Lies (From: Maurice Volaski <email@hidden>)

  • Prev by Date: Re: Memory and stringByAppendingString
  • Next by Date: Re: full-screen window?
  • Previous by thread: [BUG] NSSelectorFromString Sometimes Lies
  • Next by thread: NSOutlineView expand by default?
  • Index(es):
    • Date
    • Thread