0

This same error has happened before in different contexts.

I only created a new NotificationServiceExtension and I tried get reference to AppDelegate by

- (AppDelegate *)appDelegate
{
    return (AppDelegate *)[[UIApplication sharedApplication] delegate];
}

I get following compile time error.

'sharedApplication()' is unavailable: Use view controller based solutions where appropriate instead.

I have no cocoapod dependency etc.

How can I resolve this issue? Any build settings that I change?

GJain
  • 5,025
  • 6
  • 48
  • 82
  • 1
    Your extension doesn't run inside your application, you can't access your app delegate – dan Dec 14 '16 at 19:19
  • @dan Does that mean I cannot have access to any of apps resources from extension like core data? I mean is it possible at all to update apps core data from notification extension?? – GJain Dec 14 '16 at 19:22
  • 1
    that means that you have no appdelegate from the extension point of view, so what you can do is move the core data code to another class common for all targets – Ponja Dec 14 '16 at 19:25
  • 1
    There are ways to share data between your app and your extension, see: http://stackoverflow.com/questions/25407428/how-to-access-coredata-model-in-today-extension-ios – dan Dec 14 '16 at 19:26

0 Answers0