草庐IT

anonymous-delegates

全部标签

ios - 如何为 cpp 类创建 objective-c 委托(delegate)?

我一直在尝试将openGL-es(xcodeopenGL游戏模板与powervr3.0sdk的ogles2tools库结合起来。我的问题是我加载效果文件的代码行:/*Loadtheeffect.Wepass'this'asanargumentaswewishtoreceivecallbacksasthePFXisloaded.ThisisoptionalandsupplyingNULLimpliesthatthedeveloperwilltakecareofalltextureloadingandbindingtototheEffectinstead.*/if(m_pEffect->L

ios - 在 Objective-c 问题中访问委托(delegate)静态方法

我在objective-c中遇到了一个奇怪的问题。这是代码:STViewController.h#import@interfaceSTViewController:UIViewController+(void)myStaticMethod;@endSTViewController.m#import"STViewController.h"@implementationSTViewController-(void)viewDidLoad{[superviewDidLoad];[STViewControllermyStaticMethod];}+(void)myStaticMethod{UI

ios - 更改委托(delegate)方法的参数类型

我有一个NSURL委托(delegate)方法,它接受NSInteger作为参数-(void)connection:(NSURLConnection*)connectiondidSendBodyData:(NSInteger)bytesWrittentotalBytesWritten:(NSInteger)totalBytesWrittentotalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWriteNSInteger是一个带符号的长整数,范围为-2147483647到2147483647。我的问题是有时我得到的值超出正数范

iOS 8 : When App in Background CBCentralManager Delegate Method didDiscoverPeripheral, didConnectPeripheral、didFailToConnectPeripheral 未调用

我在iOS8中使用Xcode6。当应用程序在后台运行时,我正在尝试搜索和连接蓝牙设备。我正在使用核心蓝牙框架。我使用Xcode功能选项添加了蓝牙中心和蓝牙外围设备。代码:Appdelegate.h@interfaceWSAppDelegate:UIResponder@property(strong,nonatomic)NSString*savedUUID;@property(strong,nonatomic)CBCentralManager*CBCM;AppDelegate.m-(void)applicationDidEnterBackground:(UIApplication*)ap

ios - 使用 self.delegate 子类化 UITextField 会导致应用程序卡住,CPU 峰值达到 100%

我有一个UITextField的子类,它设置了self.delegate=self。该子类用于防止将特殊字符输入到UITextField中。起初它工作正常,但在按下几个键后,CPU峰值达到100%并卡住了应用程序。Xcode中没有崩溃日志,因为该应用程序从未真正崩溃过,它只是保持卡住状态,直到我停止它。经过一些研究,我确定问题是将delegate设置为self-显然我应该为UITextField创建一个单独的delegate?我在网上搜索过,但找不到任何关于如何执行此操作的有用信息。我的AcceptedCharacters子类:AcceptedCharacters.h#import@i

ios - 如何使用 objective-c 停止和启动应用程序委托(delegate)计时器?

我在我的应用程序登录和注销过程中遇到了很多后台计时器服务过程的问题。下面的代码是我在applicationDidBecomeActive时为通知和JSON服务后台维护的。-(void)applicationDidBecomeActive:(UIApplication*)application{checkJSONtimer=[NSTimerscheduledTimerWithTimeInterval:300target:selfselector:@selector(updateJSON)userInfo:nilrepeats:TRUE];NSLog(@"%s",__PRETTY_FUNC

ios - 位置管理器委托(delegate)不叫 iOS swift

我在infoplist中设置了键NSLocationAlwaysUsageDescription、NSLocationWhenInUseUsageDescription并运行下面的代码,委托(delegate)不会被调用,位置弹出窗口有时会出现很短的时间:类LocationFinder:NSObject,CLLocationManagerDelegate{enumLocationSettingStatus:Int{caseValue}classvarsharedInstance:LocationFinder{structStatic{staticvarinstance:Location

ios - Application delegate 在我们的 Cocoa/Cocoa-touch 应用中在哪里注册

每个应用程序都有一个应用程序委托(delegate)。在我们指定/注册“SomeClass”(UIApplicationDelegate的子类)是我的应用程序的委托(delegate)的代码中的什么位置? 最佳答案 如果您使用Storyboarding,则在main.m中使用以下行完成:UIApplicationMain(argc,argv,nil,NSStringFromClass([AppDelegateclass]));如果UIApplicationMain()的第四个参数不是nil,该函数将创建指定类的实例并将其分配为UIA

ios - Objective-C:将代码注入(inject)委托(delegate)方法

我想要什么我想在我的应用程序中添加一些日志记录代码,而不必更新我所有的ViewController。我尝试过的我试图将一个类别添加到UIViewController并覆盖其中一个委托(delegate)方法。但是,这产生了几个警告/错误。有没有办法将代码注入(inject)到我应用的所有ViewController中? 最佳答案 查看methodswizzling.它是一个强大的工具,可以为您节省大量时间。调配您希望登录的方法之一,然后调用原始方法让它执行它最初应该做的事情。 关于ios

ios - NSURLSession委托(delegate)Queue的maxConcurrentOperationCount是如何影响任务并发的

我正在使用AFNetworking3.0,它使用NSURLSessionDataTask和一个operationQueue(AFURLSessionManager的属性),用作NSURLSession简单的说AFURLSessionManager.operationQueue==NSURLSession.delegateQueueAFNetworking3代码self.operationQueue=[[NSOperationQueuealloc]init];self.operationQueue.maxConcurrentOperationCount=1;self.session=[N