how to call a method of multiple arguments with delay

use dispatch_after: double delayInSeconds = 2.0; dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ //code to be executed on the main queue after delay [self MoveSomethingFrom:from To:to]; }); EDIT 2015: For Swift, i recommend using this small helper method: dispatch_after – GCD in swift?

Swift access control with target selectors

you need @objc to expose a private method to objc runtime @objc private func buttonDidTap(button:UIButton!) { println(button.char) } From Xcode6 beta4 release notes Declarations marked private are not exposed to the Objective-C runtime if not otherwise annotated. IB outlets, IB actions, and Core Data managed properties remain exposed to Objective-C whatever their access level. If …

Read more

List selectors for Objective-C object

This is a solution based on the runtime C functions: class_copyMethodList returns a list of class methods given a Class object obtainable from an object. #import <objc/runtime.h> [..] SomeClass * t = [[SomeClass alloc] init]; int i=0; unsigned int mc = 0; Method * mlist = class_copyMethodList(object_getClass(t), &mc); NSLog(@”%d methods”, mc); for(i=0;i<mc;i++) NSLog(@”Method no #%d: …

Read more

Objective-C: How to call performSelector with a BOOL typed parameter?

In the case that you cannot alter the target-method signature to accept a NSNumber in place of a BOOL you can use NSInvocation instead of performSelector: MyTargetClass* myTargetObject; BOOL myBoolValue = YES; // or NO NSMethodSignature* signature = [[myTargetObject class] instanceMethodSignatureForSelector: @selector( myMethodTakingBool: )]; NSInvocation* invocation = [NSInvocation invocationWithMethodSignature: signature]; [invocation setTarget: myTargetObject]; [invocation setSelector: …

Read more

Selector in swift3

Selector(“tap:”) should now be written as #selector(tap(gestureReconizer:)) Also, you should declare tap as func tap(_ gestureRecognizer: UITapGestureRecognizer) as per the new Swift API Guidelines in which case your selector would then become #selector(tap(_:)).