Questions tagged [selector]

A selector can be a string identifying a method name in the Objective-C or Smalltalk programming language or a special kind of switch used in computers to connect multiple lines (I/O) to a single line. Please do not use this tag for jQuery/CSS selectors.

A selector can be a:

  • string identifying a method name in the Objective-C or Smalltalk programming language.
  • special kind of switch used in computers to connect multiple lines (I/O) to a single line.

  • CSS selector, which determines how style rules are applied to a document.
    For this purpose, please use instead.

  • jQuery/Sizzle selector, a notation that borrows from CSS syntax and adds custom extensions.
    For this purpose, please use instead.

3870 questions
697
votes
24 answers

@selector() in Swift?

I'm trying to create an NSTimer in Swift but I'm having some trouble. NSTimer(timeInterval: 1, target: self, selector: test(), userInfo: nil, repeats: true) test() is a function in the same class. I get an error in the editor: Could not find an…
Arbitur
  • 38,684
  • 22
  • 91
  • 128
217
votes
17 answers

What is the Swift equivalent of respondsToSelector?

I've googled but not been able to find out what the swift equivalent to respondsToSelector: is. This is the only thing I could find (Swift alternative to respondsToSelector:) but isn't too relevant in my case as its checking the existence of the…
Gruntcakes
  • 37,738
  • 44
  • 184
  • 378
175
votes
41 answers

"unrecognized selector sent to instance" error in Objective-C

I created a button and added an action for it, but as soon as it invoked, I got this error: -[NSCFDictionary numberButtonClick:]: unrecognized selector sent to instance 0x3d03ac0 2010-03-16 22:23:58.811 Money[8056:207] *** Terminating app due to…
HelloWorld
  • 7,156
  • 6
  • 39
  • 36
169
votes
12 answers

How to get rid of the 'undeclared selector' warning

I want to use a selector on an NSObject instance without the need for an implemented protocol. For example, there's a category method that should set an error property if the NSObject instance it's called on supports it. This is the code, and the…
epologee
  • 11,229
  • 11
  • 68
  • 104
148
votes
8 answers

Objective-C: Calling selectors with multiple arguments

In MyClass.m, I've defined - (void) myTest: (NSString *) withAString{ NSLog(@"hi, %@", withAString); } and the appropriate declaration in MyClass.h . Later I want to call [self performSelector:@selector(mytest:withAString:) withObject:…
Stu
  • 2,679
  • 4
  • 26
  • 25
132
votes
6 answers

android button selector

This is a button selector such that when normal it appears red, when pressed it appears grey. I would like to ask how could the code be further directly modified such that when PRESSED the text size and color could also change? Many thanks!
pearmak
  • 4,979
  • 15
  • 64
  • 122
129
votes
8 answers

Selectors in Objective-C?

First, I'm not sure I really understand what a selector is. From my understanding, it's the name of a method, and you can assign it to a class of type 'SEL' and then run methods such as respondToSelector to see if the receiver implements that…
Craig
  • 16,291
  • 12
  • 43
  • 39
119
votes
5 answers

Android: textColor of disabled button in selector not showing?

I am trying to make a button with a selector my button can have the following states: Enabled/Disabled Pressed/Not Pressed According to the states mentioned above. I need to manipulate the button's: Text color background image The button starts…
Nouran H
  • 1,992
  • 5
  • 18
  • 24
118
votes
4 answers

cancelling queued performSelector:afterDelay calls

does anybody know if it is possible to cancel already queued selector events from the event stack or timer stack (or whatever mechanism it is that is utilized by the API) when you call performSelector:withObject:afterDelay? I was using this event…
eerok512
  • 1,357
  • 2
  • 10
  • 16
117
votes
5 answers

Using -performSelector: vs. just calling the method

I'm still kind of new to Objective-C and I'm wondering what is the difference between the following two statements? [object performSelector:@selector(doSomething)]; [object doSomething];
TheGambler
  • 3,711
  • 5
  • 38
  • 54
107
votes
6 answers

Passing arguments to selector in Swift

I'm programmatically adding a UITapGestureRecognizer to one of my views: let gesture = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(modelObj:myModelObj))) self.imageView.addGestureRecognizer(gesture) func…
mike
  • 2,073
  • 4
  • 20
  • 31
104
votes
6 answers

When to use @objc in Swift?

In Swift, I see some methods like: @objc private func doubleTapGestureRecognized(recognizer: UITapGestureRecognizer) I was wondering, when to use @objc? I read some documents, but they are saying when you want it to be callable in Objective-C, you…
Wingzero
  • 9,644
  • 10
  • 39
  • 80
95
votes
10 answers

How do I select a sibling element using jQuery?

Can you help me with this jQuery selector? $(".auctiondiv .auctiondivleftcontainer .countdown").each(function () { var newValue = parseInt($(this).text(), 10) - 1; $(this).text(newValue); if (newValue == 0) { …
Only Bolivian Here
  • 35,719
  • 63
  • 161
  • 257
91
votes
11 answers

iOS - How to implement a performSelector with multiple arguments and with afterDelay?

I am an iOS newbie. I have a selector method as follows - - (void) fooFirstInput:(NSString*) first secondInput:(NSString*) second { } I am trying to implement something like this - [self performSelector:@selector(fooFirstInput:secondInput:)…
Suchi
  • 9,989
  • 23
  • 68
  • 112
91
votes
9 answers

How to apply shape and selector simultaneously for Button?

I have applied a shape for a button like:
Khawar Raza
  • 15,870
  • 24
  • 70
  • 127
1
2 3
99 100