How do I resolve “ambiguous use of” compile error with Swift #selector syntax?

[NOTE This answer was originally formulated under Swift 2.2. It has been revised for Swift 4, involving two important language changes: the first method parameter external is no longer automatically suppressed, and a selector must be explicitly exposed to Objective-C.] You can work around this problem by casting your function reference to the correct method … Read more

Why must the last part of an Objective-C method name take an argument (when there is more than one part)?

This is Brad Cox. My original answer misunderstood the question. I assumed reallyFast was a hardcoded extension to trigger faster messaging, not a kind of syntactic sugar. The real answer is that Smalltalk didn’t support it, perhaps because its parser couldn’t deal with the (assumed) ambiguity. Although OC’s square brackets would remove any ambiguity, I … Read more

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

Personally, I think that a closer solution to your needs is the use of NSInvocation. Something like the following will do the work: indexPath and dataSource are two instance variables defined in the same method. SEL aSelector = NSSelectorFromString(@”dropDownSelectedRow:withDataSource:”); if([dropDownDelegate respondsToSelector:aSelector]) { NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[dropDownDelegate methodSignatureForSelector:aSelector]]; [inv setSelector:aSelector]; [inv setTarget:dropDownDelegate]; [inv setArgument:&(indexPath) atIndex:2]; … Read more

Android: textColor of disabled button in selector not showing?

You need to also create a ColorStateList for text colors identifying different states. Do the following: Create another XML file in res\color named something like text_color.xml. <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <!– disabled state –> <item android:state_enabled=”false” android:color=”#9D9FA2″ /> <item android:color=”#000″/> </selector> In your style.xml, put a reference to that text_color.xml file as follows: <style … Read more

Using -performSelector: vs. just calling the method

Basically performSelector allows you to dynamically determine which selector to call a selector on the given object. In other words the selector need not be determined before runtime. Thus even though these are equivalent: [anObject aMethod]; [anObject performSelector:@selector(aMethod)]; The second form allows you to do this: SEL aSelector = findTheAppropriateSelectorForTheCurrentSituation(); [anObject performSelector: aSelector]; before you … Read more

cancelling queued performSelector:afterDelay calls

[NSObject cancelPreviousPerformRequestsWithTarget:] or [NSObject cancelPreviousPerformRequestsWithTarget:selector:object:] The target is the original object on which performSelector:afterDelay: was called. For example: // schedule the selector [self performSelector:@selector(mySel:) withObject:nil afterDelay:5.0]; // cancel the above call (and any others on self) [NSObject cancelPreviousPerformRequestsWithTarget:self]; See apple docs, it’s right at the end of the performSelector:withObject:afterDelay: description.

Selectors in Objective-C?

You have to be very careful about the method names. In this case, the method name is just “lowercaseString“, not “lowercaseString:” (note the absence of the colon). That’s why you’re getting NO returned, because NSString objects respond to the lowercaseString message but not the lowercaseString: message. How do you know when to add a colon? … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)