草庐IT

delegating-constructor

全部标签

ios - 为什么 AVSampleBufferDisplayLayer 停止显示从 AVCaptureVideoDataOutput 的委托(delegate)中获取的 CMSampleBuffers?

我想用AVSampleBufferDisplayLayer显示一些CMSampleBuffer,但它在显示第一个示例后卡住。我从AVCaptureVideoDataOutputSampleBuffer委托(delegate)中获取样本缓冲区:-(void)captureOutput:(AVCaptureOutput*)captureOutputdidOutputSampleBuffer:(CMSampleBufferRef)sampleBufferfromConnection:(AVCaptureConnection*)connection{CFRetain(sampleBuffer)

hibernate - 带有 JPA : default constructor hell 的 Kotlin

根据JPA的要求,@Entity类应该有一个默认(非arg)构造函数,以便在从数据库中检索对象时实例化它们。在Kotlin中,在主构造函数中声明属性非常方便,如下例所示:classPerson(valname:String,valage:Int){/*...*/}但是当非参数构造函数被声明为辅助构造函数时,它需要传递主构造函数的值,因此它们需要一些有效值,如下所示:@EntityclassPerson(valname:String,valage:Int){privateconstructor():this("",0)}如果属性有一些比String和Int更复杂的类型并且它们不可为空,那

hibernate - 带有 JPA : default constructor hell 的 Kotlin

根据JPA的要求,@Entity类应该有一个默认(非arg)构造函数,以便在从数据库中检索对象时实例化它们。在Kotlin中,在主构造函数中声明属性非常方便,如下例所示:classPerson(valname:String,valage:Int){/*...*/}但是当非参数构造函数被声明为辅助构造函数时,它需要传递主构造函数的值,因此它们需要一些有效值,如下所示:@EntityclassPerson(valname:String,valage:Int){privateconstructor():this("",0)}如果属性有一些比String和Int更复杂的类型并且它们不可为空,那

ios - Xcode 6.3/iOS 8.3 中的新功能 : using self alloc for convenience constructor causes build error

此代码在Xcode6.2和6.3之间没有变化,但包含[selfalloc]的行现在导致错误:发现多个名为“initWithType:”的方法具有不匹配的结果、参数类型或属性@implementationAGNetworkDataRequest+(instancetype)networkDataRequestWithType:(AGNetworkDataRequestType)type{AGNetworkDataRequest*r=[[selfalloc]initWithType:type];//errorherereturnr;}-(id)initWithType:(AGNetwork

iphone - 声明委托(delegate)协议(protocol)

我想知道在同一个类中声明一个protocol和在一个单独的文件中声明它有什么区别;示例:#import@classMyClassA;@protocolMyDelegate@required-(MyClassA*)myMythod;@optional-(void)anOtherMethod:(NSString*)ID;@end@interfaceMyClassB:UIViewController@property(nonatomic,assign)iddelegate;......在这里,我在与MyClassB相同的文件中声明协议(protocol)委托(delegate),我可以在单独

iphone - 在没有任何导航 Controller 连接的情况下使用 View Controller 之间的委托(delegate)传递数据

有很多在两个ViewController之间传递数据的示例,其中一个ViewController导航到另一个ViewController。但是是否可以在未通过导航Controller连接的ViewController之间使用自定义协议(protocol)和委托(delegate)传递数据?因此,一个示例可能是:三个ViewController,即A、B、C。A导航到B,B导航到C。我知道如何使用自定义协议(protocol)和委托(delegate)在A和B之间传递数据。但是我们可以在C和A之间传递数据吗?因此A可以是C的委托(delegate),从而可以从C接收数据。这可能吗?如有任

ios - 选项卡栏确实选择了委托(delegate)方法在 ios 中给出了先前选择的选项卡索引,swift 3

我正在尝试实时检测用户选择了哪个选项卡。例如,如果用户选择0th索引,同时我想让该用户选择了zeroth索引选项卡。所以为此,我使用了如下所示的tabbarcontroller委托(delegate)方法。overridefunctabBar(_tabBar:UITabBar,didSelectitem:UITabBarItem){print("theselectedindexis:\(selectedIndex)")}但这显示了前一个ViewController。举个例子,假设我在secondtab中,然后我选择firsttab然后将索引打印为2.so我怎样才能得到正确的选择标签。希

iphone - iOS在调用方法之前检查委托(delegate)是否存在

我编写iOS应用程序并使用imageStore库延迟加载图像并将它们缓存在内存中。(https://github.com/psychs/imagestore)我在ViewController上创建图像存储实例:imageStore=[ImageStorenew];imageStore.delegate=self;图片加载成功后,imagestore调用委托(delegate)方法-(void)imageStoreDidGetNewImage:(ImageStore*)senderurl:(NSString*)url在tableview上执行reloadData以重绘单元格。一切正常。但

iphone - 在调用 respondsToSelector 之前检查委托(delegate)是否仍然存在

我制作了一个UIView子类来处理iAds和adMob。ViewController是子类委托(delegate),一切正常。然而,有时,ViewController会在获取广告之前消失。为了解决这个问题,我在ViewController的dealloc实现中将delegate设置为nil。我遇到的问题是,有时respondsToSelector:方法会在ViewController被释放的同时运行。这会导致崩溃。有谁知道我该如何重新安排这个?广告View在大约10个不同的ViewController上,所以我想要一个地方来创建广告代码。非常感谢 最佳答案

ios - 委托(delegate)成为噩梦的多层 subview Controller ——它们应该如何相互通信?

这对我来说是个严重的问题。在代码库上工作,多层subviewController大约有4-5层深-这是一款平板电脑应用程序,ViewController之间的解耦程度非常高。第5层subviewController想要向顶层ViewController发送消息以显示模态。第4层和第3层也有不同的消息,所以基本上现在我有4个协议(protocol),从嵌套在内部深处的subviewController向祖先ViewController发送消息变得非常复杂。有更简单的方法吗?我们考虑过使用NSNotification但并不是特别喜欢它,因为它很难调试,而且订阅不是我们控制范围内的明确依赖项