草庐IT

APPDELEGATE

全部标签

ios - 在 Xcode 7 中更改了 +load 方法顺序

我发现Xcode7(版本7.0(7A220))更改了+load的顺序在单元测试期间调用类和类别的方法。如果属于测试目标的类别实现了+load方法,它现在在最后调用,此时类的实例可能已经被创建和使用。我有一个AppDelegate,它实现了+load方法。AppDelegate.m文件还包含AppDelegate(MainModule)类别。此外,还有一个单元测试文件LoadMethodTestTests.m,其中包含另一个类别–AppDelegate(UnitTest).这两个类别还实现了+load方法。第一类属于主要目标,第二类属于测试目标。代码我做了一个小testproject来证

ios - 在 Xcode 7 中更改了 +load 方法顺序

我发现Xcode7(版本7.0(7A220))更改了+load的顺序在单元测试期间调用类和类别的方法。如果属于测试目标的类别实现了+load方法,它现在在最后调用,此时类的实例可能已经被创建和使用。我有一个AppDelegate,它实现了+load方法。AppDelegate.m文件还包含AppDelegate(MainModule)类别。此外,还有一个单元测试文件LoadMethodTestTests.m,其中包含另一个类别–AppDelegate(UnitTest).这两个类别还实现了+load方法。第一类属于主要目标,第二类属于测试目标。代码我做了一个小testproject来证

ios - 除了从 appDelegate 获取之外,如何获取 viewController 的 managedObjectContext?

最近我了解到“您真的不应该调用AppDelegate来获取托管对象上下文”。Apple也已将此建议放入其文档中here.它是这样的:Aviewcontrollertypicallyshouldn’tretrievethecontextfromaglobalobjectsuchastheapplicationdelegate—thismakestheapplicationarchitecturerigid.Neithershouldaviewcontrollercreateacontextforitsownuse(unlessit’sanestedcontext).Thismaymean

ios - 除了从 appDelegate 获取之外,如何获取 viewController 的 managedObjectContext?

最近我了解到“您真的不应该调用AppDelegate来获取托管对象上下文”。Apple也已将此建议放入其文档中here.它是这样的:Aviewcontrollertypicallyshouldn’tretrievethecontextfromaglobalobjectsuchastheapplicationdelegate—thismakestheapplicationarchitecturerigid.Neithershouldaviewcontrollercreateacontextforitsownuse(unlessit’sanestedcontext).Thismaymean

objective-c - 得到 "Duplicate Interface Definition"错误,肯定要#import ing 头文件

我正在帮助一个iOS项目,其中包含AppDelegate中许多不同类共有的许多方法和定义。因此,在这些类的每一个中,在.h文件中,我使用#import"AppDelegate.h"。在我需要访问已经将AppDelegate导入到另一个导入AppDelegate的类中的那些类中之前,这工作正常。此时,我收到AppDelegate的重复接口(interface)定义错误。好吧,这看起来很公平。我已经将AppDelegate导入到我正在导入的文件中,因此AppDelegate是从两个不同的地方导入的。所以我删除了AppDelegate行,一切都很好。但是当我需要导入两个都需要导入AppDel

objective-c - 得到 "Duplicate Interface Definition"错误,肯定要#import ing 头文件

我正在帮助一个iOS项目,其中包含AppDelegate中许多不同类共有的许多方法和定义。因此,在这些类的每一个中,在.h文件中,我使用#import"AppDelegate.h"。在我需要访问已经将AppDelegate导入到另一个导入AppDelegate的类中的那些类中之前,这工作正常。此时,我收到AppDelegate的重复接口(interface)定义错误。好吧,这看起来很公平。我已经将AppDelegate导入到我正在导入的文件中,因此AppDelegate是从两个不同的地方导入的。所以我删除了AppDelegate行,一切都很好。但是当我需要导入两个都需要导入AppDel

iphone - remoteControlReceivedWithEvent 未在 appDelegate 中调用

我在使用avplayer控制iPhone控件时遇到问题。如果我输入函数-(void)remoteControlReceivedWithEvent:(UIEvent*)event在负责播放所调用函数的ViewController中,但前提是我要在当前ViewController中返回后台。如果我要从其他ViewController进入后台,则该函数永远不会被调用。这就是为什么我想把它放在应用程序委托(delegate)中。我尝试了Becomefirstresponse并将该函数放入每个ViewController中,但它确实有帮助。我也打电话[[UIApplicationsharedAp

iphone - remoteControlReceivedWithEvent 未在 appDelegate 中调用

我在使用avplayer控制iPhone控件时遇到问题。如果我输入函数-(void)remoteControlReceivedWithEvent:(UIEvent*)event在负责播放所调用函数的ViewController中,但前提是我要在当前ViewController中返回后台。如果我要从其他ViewController进入后台,则该函数永远不会被调用。这就是为什么我想把它放在应用程序委托(delegate)中。我尝试了Becomefirstresponse并将该函数放入每个ViewController中,但它确实有帮助。我也打电话[[UIApplicationsharedAp

ios - 从 App Delegate 呈现 View Controller

我正在尝试使用以下代码从应用程序委托(delegate)中呈现一个ViewController:-(void)interstitialViewControllerRequestSucceeded:(UIViewController*)interstitialViewController{[self.window.rootViewControllerpresentViewController:(UIViewController*)interstitialViewControlleranimated:YEScompletion:NULL];}它将在初始ViewController上显示插页

ios - 从 App Delegate 呈现 View Controller

我正在尝试使用以下代码从应用程序委托(delegate)中呈现一个ViewController:-(void)interstitialViewControllerRequestSucceeded:(UIViewController*)interstitialViewController{[self.window.rootViewControllerpresentViewController:(UIViewController*)interstitialViewControlleranimated:YEScompletion:NULL];}它将在初始ViewController上显示插页