James
James

Reputation: 301

Using NSTimer to fire a method on Previous Controller

Lets say I have a ViewController1 and a ViewController2. I segued from VC1 to VC2. So I am in ViewController 2 and I want to use

[NSTimer scheduledTimerWithTimeInterval:10 target: selector: userInfo:nil repeats:NO] 

to execute a method on ViewController1 (let's call it method1.) What are the parameters for NSTimer? Thanks

Upvotes: 0

Views: 44

Answers (2)

cjnevin
cjnevin

Reputation: 311

Why are you trying to do this? I'd use a delegate (protocol) and let VC1 handle the timing in case VC2 is destroyed.

On segue:

VC2.delegate = VC1

On event:

self.delegate.firedEvent()

On VC1:

func firedEvent() {
    // delay here
}

Upvotes: 1

ronhippler
ronhippler

Reputation: 106

target: ViewController1 selector: @selector(method1:)

see also: How do I use NSTimer?

Upvotes: 0

Related Questions