Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!dali.cs.montana.edu!milton!wiml From: wiml@milton.u.washington.edu (William Lewis) Newsgroups: comp.sys.next Subject: Re: Question about Objective-C's @selector Message-ID: <5144@milton.u.washington.edu> Date: 16 Jul 90 23:02:30 GMT References: <26a20030.3d07@petunia.CalPoly.EDU> Distribution: na Organization: University of Washington, Seattle Lines: 27 In article <26a20030.3d07@petunia.CalPoly.EDU> mdeale@vega.acs.calpoly.edu (Myron Deale) writes: >I have something like > >[listObject makeObjectsPerform:(SEL)aSelector with:anObject]; > >but can "aSelector" only be a constant? > >I have a radio button matrix that inputs a choice between a number of >different methods. I would like to set some kind of pointer (ala C's >pointer to function), based upon the radio button input, though >aSelector would have to be a variable rather than a constant literal. What's wrong with doing something along the lines of static SEL selectors[] = { @selector("foo:"), @selector("bar:"), @selector("doom:") }; ... [listObject makeObjectsPerform:selectors[[sender selectedTag]] with:anObject]; ... -- wiml@blake.acs.washington.edu Seattle, Washington | No sig under (William Lewis) | 47 41' 15" N 122 42' 58" W |||||||| construction