-6

I have one appdelegate and notifyviewcontroller class.

declare one method -(void)getNotificaionform in notifyviewcontroller.

I want to call this method in appdelegate applicationDidBecomeActive and applicationDidEnterBackground .

How can i achieve this help me?

I'm new to development.

Deepesh
  • 8,065
  • 3
  • 28
  • 45
saravanaa
  • 9
  • 9
  • possible duplicate of [Calling UIViewController method from app delegate](http://stackoverflow.com/questions/18950670/calling-uiviewcontroller-method-from-app-delegate) – jscs Feb 12 '15 at 21:15

2 Answers2

0
for (UIViewController * vc in Nvc.viewControllers) {
    if ([vc isKindOfClass:notifyviewcontroller Class]) {
        [vc getNotificaionform];
    }
}

Use this code in your applicationDidEnterBackground and Here Nvc is an object of UINavigationController .

navroz
  • 382
  • 2
  • 13
0

For you appDelegate to know about your UIViewController sub class you must import its header.

So in your AppDelegate.m add -

#import "NotifyViewController.h"

Then assuming your rootViewController is of this class you can access it anywhere in your AppDelegate.m and send it a message using -

[(NotifyViewController*)self.window.rootViewController importNotificationForm];// I changed the method name slightly as I don't like to use get with a method of type void

Note the typecast and also please start class names with a capital letter and use camel case. Follow naming conventions for easier to read code.

Bamsworld
  • 5,670
  • 2
  • 32
  • 37