草庐IT

AT_appDelegate

全部标签

iphone - "[context save:&error]"和 "[appDelegate saveContext]"之间的区别

我目前正在编写一个使用CoreData的应用程序,并在Apple的文档中阅读它。我意识到当我在Xcode4中创建一个基于窗口的应用程序时,它会自动添加一个实例方法:-(void)saveContext;但在“aroundtown”(大多数教程)的示例中,我总是看到人们使用:[contextsave:&error];使用其中一种有哪些不同的情况? 最佳答案 那不是类方法,是实例方法[contextsave:&error]让我们检查错误并显式处理它最好在调用save:时使用if()(即不要只检查error)据推测,saveContext

ios - 从框架访问 AppDelegate?

我正在用Objective-C创建我的第一个框架,它以更直观的方式包装了facebookSDK。在我的框架中有几个点我想引用AppDelegate,但是当您创建静态CocoaTouch库时没有appdelegate。我怎样才能引用它?我想引用我的框架链接到的xcode项目的应用程序委托(delegate)。 最佳答案 如果您正在创建一个框架,那么整个想法就是让它具有可移植性。将框架绑定(bind)到应用程序委托(delegate)违背了构建框架的目的。您需要应用委托(delegate)有什么用?

ios - 将 AppDelegate 用作单例

我正在使用我的AppDelegate来处理一些音频文件。我已将其设为AVAudioPlayer委托(delegate),因此我可以使用audioPlayerDidFinishPlaying等方法。我是这样做的:@interfaceAppDelegate:UIResponder然后在任何ViewController中,我通过以下方式访问我的AppDelegate:AppDelegate*appDelegate=[[UIApplicationsharedApplication]delegate];一切正常,但我收到以下警告:Assigningto'APPDelegate*__strong'

ios - 带有单例 AppDelegate 的台风

我正在使用带有“Plist集成”的台风我在程序集中定义了AppDelegate如下:-(AppDelegate*)appDelegate{return[TyphoonDefinitionwithClass:[AppDelegateclass]configuration:^(TyphoonDefinition*definition){[definitioninjectProperty:@selector(window)];definition.scope=TyphoonScopeSingleton;}];}在window中,我有一个rootViewController和一个由AppDel

iOS/Metal : how to read from the depth buffer at a point?

我想从深度缓冲区中读取。在OSX上的GL中我可以这样做:floatdepth[2][2];//get2x2forbilinearinterpolationglReadPixels(s.x,s.y,/*width*/2,/*height*/2,GL_DEPTH_COMPONENT,GL_FLOAT,depth);(请注意,使用iOS上的OpenGLES时,您无法从深度缓冲区中读取数据)Metal的等价物是什么?看起来我需要做:_renderPassDescriptor.depthAttachment.storeAction=MTLStoreActionStore;然后以某种方式通过CPU

ios - 可以在运行时更改 AppDelegate

是否可以在运行时将UIApplication.delegate属性更改为另一个实现UIApplicationDelegate协议(protocol)的类,以便从那时起在新类上调用UIApplicationDelegate函数? 最佳答案 您可以使用[UIApplicationsharedApplication].delegate=instanceOfDifferentClass非常简单地更改它。 关于ios-可以在运行时更改AppDelegate,我们在StackOverflow上找到一

iphone - 试图在 appDelegate 中保存 NSManagedObject

当我尝试在委托(delegate)中保存NSManageObject时,我遇到了很多麻烦,最糟糕的问题是尝试读取对象。我的代表是这样的:@classViewController;@classRootViewController;@interfaceAppDelegate:UIResponder{NSManagedObjectModel*managedObjectModel;NSManagedObjectContext*managedObjectContext;NSPersistentStoreCoordinator*persistentStoreCoordinator;Trips*tr

ios - 如何在 AppDelegate 中获取 Storyboard UITabBarController 的指针

我正在使用Storyboard来创建我的应用程序。我的应用程序的根是一个UITabBarController。如何从我的ApplicationDelegate中访问我的tabBarController?我设法从我的一个UIViewController中成功地实现了操作。但我想将代码移至我的应用程序委托(delegate)。我怎样才能做到这一点?我以为我可以从Storyboard中拖放到我的应用程序委托(delegate)中,然后得到类似的东西@property(nonatomic,strong)IBOutletUITabBarController*tabBarController;但这

ios - 构建应用程序时 Xcode 9 Main.storyboard 错误 "Internal error. Please file a bug at bugreport.apple.com and attach "

我在去年在Xcode8中构建的Xcode项目中遇到了这个错误,现在我试图在Xcode9GM中打开它。编辑仔细检查,我注意到它没有使用GM,我使用的是Xcode9.1beta2。下面的解决方案有效!错误:/Users/XXXX/Documents/AppDevelopment/FinalApps/XXXX/Base.lproj/Main.storyboard:Internalerror.Pleasefileabugatbugreport.apple.comandattach"/var/folders/ln/n28_nbyn2cg9_5dfqfsj8_7w0000gn/T/IB-agent

iphone - iOS:对正确使用 AppDelegate 感到困惑

对于iOS开发人员来说仍然是个新手(有asp.net/web的背景),而且我不认为我已经完全理解所有事情之间的关系。例如,我目前正在构建一个以NavigationController开头的应用程序。我很高兴地传入和传出ViewControllers,一切正常,但现在我需要向导航Controller添加一个右键。我已经从这样的ViewControllers之一中完成了此操作:-(void)viewDidLoad{UIBarButtonItem*change=[[UIBarButtonItemalloc]initWithTitle:@"CHANGE"style:UIBarButtonIte