简体   繁体   English

将数据从UIViewController传递到AppDelegate

[英]Pass data from UIViewController to AppDelegate

I need to pass the data from the UIViewController to AppDelegate. 我需要将数据从UIViewController传递到AppDelegate。 But should not with NSUserDefaults. 但不应与NSUserDefaults一起使用。 I could not find an alternative for it even i don't want it. 即使我不想要它,我也找不到替代方法。

if you need access to your delegate, I always create my singleton access in the next way : 如果您需要访问您的代表,我总是以以下方式创建我的单例访问:

// your imports...

#define appDelegate ((YourAppDelegate*)[UIApplication sharedApplication].delegate)

@class YourAppDelegate

//...

in the .h file of YourAppDelegate. 在YourAppDelegate的.h文件中。

It´s helpful and useful, but do not abuse of the delegate to access to particular things, try to use a different way. 它很有帮助,也很有用,但不要滥用委托人来访问特定的事物,请尝试使用其他方式。 Anyway, you can access in that way. 无论如何,您都可以通过这种方式访问​​。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM