草庐IT

require-ified

全部标签

Swift: Overriding Self-requirement 是允许的,但会导致运行时错误。为什么?

我刚开始学习Swift(v.2.x),因为我很好奇新功能是如何发挥作用的,尤其是带有self要求的协议(protocol)。下面的示例将编译得很好,但会导致任意运行时影响的发生://TheprotocolwithSelfrequirementprotocolNarcissistic{funcgetFriend()->Self}//BaseclassthatadoptstheprotocolclassMario:Narcissistic{funcgetFriend()->Self{print("Mario.getFriend()")returnself;}}//Intermediatec

ios - 图像选择器 Controller :didFinishPickingMediaWithInfo conflicts with optional requirement method in protocol 'UIImagePickerControllerDelegate'

这是完整的错误:Objective-Cmethod'imagePickerController:didFinishPickingMediaWithInfo:'providedbymethod'imagePickerController(_:didFinishPickingMediaWithInfo:)'conflictswithoptionalrequirementmethod'imagePickerController(_:didFinishPickingMediaWithInfo:)'inprotocol'UIImagePickerControllerDelegate'它出现在我的

ios - SecPKCS12Import when p12 requires an empty passphrase

我在p12中有一个私钥,它设置了空密码。现在,当我尝试在OSX或iOS上使用SecPKCS12Import导入此私钥时,出现错误(在Windows上是等效的)。-(NSError*)setClientIdentityCertificateFromPKCS12Data:(NSData*)PKCS12DatawithPassword:(NSString*)password{OSStatussecurityError=errSecSuccess;constvoid*keys[]={kSecImportExportPassphrase};constvoid*values[]={(__bridg

ios - 'required' initializer 'init(coder:)' 必须由 'UITableViewCell' 的子类提供`

据说此代码有效here和here,但我似乎无法让它发挥作用。IBOutlets连接到Storyboard中的对象。prototypeCell已命名,因此我可以将它与dequeueReusableCellWithIdentifier一起使用,并且它的自定义类属性设置为commentCell。第一个错误(我可以解决,但上面的链接都不需要它,这让我觉得我做错了什么。我是对的吗?):Overridingmethodwithselector'initWithStyle:reuseIdentifier:'hasincompatibletype'(UITableViewCellStyle,Strin

ios - 应用程序(_ :didFinishLaunchingWithOptions:)' nearly matches optional requirement

安装Xcode8beta6后,我收到一条警告:Instancemethod'application(_:didFinishLaunchingWithOptions:)'nearlymatchesoptionalrequirement'application(_:didFinishLaunchingWithOptions:)'ofprotocol'UIApplicationDelegate'在我的AppDelegate中。有2个建议的fixit可以消除警告:将方法标记为私有(private)在方法中添加@nonobjc做任何一个都会消除警告。但为什么需要这样做?

ios - "automatically adjusts font requires using a dynamic type text style"警告是什么意思?

我收到以下警告:"automaticallyadjustsfontrequiresusingadynamictypetextstyle"我无法摆脱main.storyboard上的警告。我检查了IdentityInspector中的每个UILabel,以确保未选中“AutomaticallyAdjustsFont”。 最佳答案 以源代码形式打开Storyboard搜索关键字“adjustsFontForContentSizeCategory”检查哪个对象具有此选项并取消选中界面构建器中的动态类型复选框。

swift - "Protocol ... can only be used as a generic constraint because it has Self or associated type requirements"是什么意思?

我正在尝试创建一个以Swift中的自定义协议(protocol)为键的字典(实际上是一个HashSet),但它在标题中给出了错误:Protocol'myProtocol'canonlybeusedasagenericconstraintbecauseithasSelforassociatedtyperequirements而且我无法理解它的正反面。protocolObserving:Hashable{}varobservers=HashSet() 最佳答案 协议(protocol)Observing继承自协议(protocol)Ha

c# - 属性为 [Required] 且可为 null 是什么意思?

[Required]和可为空的属性是什么意思?(下面的示例)似乎如果它是[Required]它不可能是null(没有值),如果它能够是null它不可能是[Required]。[Required]publicDateTime?OrderDate{get;set;} 最佳答案 使属性可为空并标记为[Required]的原因属性是为了防止发布不足的攻击。它还允许您在View中显示初始空值而不是属性的默认值。这通常是通过View模型中的值类型属性完成的。发布不足的攻击是指恶意用户修改请求以省略请求中属性的值。如果属性是DateTime(不可

c# - Contract.Requires 抛出 pex 错误

这个问题在这里已经有了答案:关闭11年前。PossibleDuplicate:HowDoYouConfigurePextoRespectCodeContracts?目前,当我运行pex探索时,我在我的类中创建的代码契约(Contract)在pex探索结果中被视为错误。我认为当您使用代码契约(Contract)运行pex探索时,契约(Contract)失败应被视为预期行为。这是导致异常的代码。测试方法:[PexMethod]publicvoidTestEquality(GuiduserId,stringusername,stringpassword,stringsecurityQuest

c# - 错误 : "an object reference is required for the non-static field, method or property..."

这个问题在这里已经有了答案:CS0120:Anobjectreferenceisrequiredforthenonstaticfield,method,orproperty'foo'(9个回答)关闭5年前。我正在用C#创建一个应用程序。它的功能是评估给定的是否为素数以及相同的交换数是否也是素数。当我在VisualStudio中构建我的解决方案时,它说“非静态字段、方法或属性需要对象引用...”。我在使用“volteado”和“siprimo”方法时遇到了这个问题。问题出在哪里,我该如何解决?namespaceConsoleApplication1{classProgram{static