Сначала добавьте свойство myScript
к AppDelegate
:
В AppDelegate.h
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) SomeScript *myScript; // Add this line
//...
@end
В AppDelegate.m
@implementation PCAppDelegate
@synthesize myScript; // Add this line
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.myScript = [[SomeScript alloc] init]; // Add this line
//...
@end
Теперь, когда вы объявили и инициализировали свойство, вы можете использовать его, как указано ниже, из других классов:
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
[appDelegate.myScript aMethod];