草庐IT

bad_cast

全部标签

ios - IPP 通过 HTTP : getting 400 bad request as a response

我在iOS上,我正在尝试发送HTTPPOST请求以通过充当IPP服务器的Mac在打印机上创建打印作业。我可以使用airprint正确打印,我现在正在尝试低级别,因为我需要将原始数据发送到打印机。关于我的代码:一切都是硬编码的。我仍在努力找出哪里出了问题,所以我只是处于开发/测试阶段。第一部分是关于IPP打印作业请求的二进制结构的定义(根据RFC2910规范,它应该是正确的)。chardata[239]={0x01,0x01,//IPPversion0x00,0x04,//Print-jobrequest0x00,0x00,0x00,0x50,//ArbitraryrequestID0x

objective-c - EXC_BAD_ACCESS 委托(delegate)崩溃

我有委托(delegate)@property(nonatomic,assign)iddelegate;但它在performSelector上崩溃if(_delegate!=nil&&[_delegateconformsToProtocol:@protocol(DelegateProtocol)]){NSObject*obj=_delegate;//HEREISEXC_BAD_ACCESS[objperformSelectorOnMainThread:@selector(didTouchImageView:)withObject:selfwaitUntilDone:NO];}我在这里设

c++ - static_cast 没有按预期处理优先级

#include#includetemplatevoidfoo(){std::coutvoidfoo(){std::cout(42)>();foo(42)>();return(0);}知道为什么这没有按预期工作吗?我的gcc4.8.1提示调用不明确,但static_cast不应该在这种情况下“修复”优先规则,在这种情况下您有2种具有相同优先级的类型? 最佳答案 您可能认为编译器在解析重载函数模板时会尝试找出哪个模板与给定参数更匹配。基于该假设,带有uint8_t的模板应该比带有int的模板更好地匹配带有uint8_t参数的函数调用。

ios - 如何在 iOS 上调试 iOS EXC_BAD_ACCESS KERN_INVALID_ADDRESS

我在使用SocketRocket时收到iOSEXC_BAD_ACCESS错误,我想知道我可以做些什么来进一步调试问题以确定问题是在我这边还是在SocketRocket那边。我得到的堆栈跟踪是:Crashed:com.apple.main-threadEXC_BAD_ACCESSKERN_INVALID_ADDRESSat0x2000000craw0libobjc.A.dylibobjc_msgSend+51OMlearningsSRWebSocket.mline692__30-[SRWebSocket_failWithError:]_block_invoke_22libdispatch

swift - EXC_BAD_ACCESS 尝试在原型(prototype)上调用函数时

这是我遇到的一个有趣的快速问题。考虑以下类和协议(protocol):classPerson{}protocolParentwhereSelf:Person{funcspeak()}classGrandMotherPerson:Person,Parent{funcspeak(){print("IamaGrandmotherPerson")}}classGrandFatherPerson:Person,Parent{funcspeak(){print("IamaGrandfatherPerson")}}letgmp=GrandMotherPerson()letgfp=GrandFathe

cocoa-touch - NSKeyedArchiver unarchiveObjectWithFile 因 EXC_BAD_INSTRUCTION 而崩溃

我有下面的代码,用来获取一个已经归档的对象的路径letpaths=NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory,NSSearchPathDomainMask.UserDomainMask,true)letpath=paths[0]asStringletarchivePath=path.stringByAppendingString("archivePath")当我运行这段代码时,它在显示lldb的NSSearchPathForDirectoriesInDomains调用时崩溃Thr

ios - LLDB( swift ): Casting Raw Address into Usable Type

是否有LLDB命令可以将原始地址转换为可用的Swift类?例如:(lldb)po0x7df67c50asMKPinAnnotationView我知道这个地址指向一个MKPinAnnotationView,但它不在我可以选择的框架中。但是,我想将原始地址转换为MKPinAnnotationView,以便我可以检查它的属性。这可能吗? 最佳答案 在Xcode8.2.1和Swift3下,lldb命令po或p将不起作用与类型变量。您将需要使用快速命令print来检查类型化对象实例的属性。(感谢cbowns'sanswer!)例如:expr-

c# - InvalidCastException : Unable To Cast Objects of type [base] to type [subclass]

我有一个继承自MembershipUser的自定义CustomMembershipUser。publicclassConfigMembershipUser:MembershipUser{//customstuff}我正在使用Linq-to-SQL从数据库中读取并获取用户实体;为了使此功能成为MembershipUser,我定义了一个显式转换:publicstaticexplicitoperatorMembershipUser(Useruser){DateTimenow=DateTime.Now;if(user==null)returnnull;returnnewMembershipUs

python - ISO 到日期时间对象 : 'z' is a bad directive

这个问题在这里已经有了答案:Converttimestampswithoffsettodatetimeobjusingstrptime(4个回答)ConvertingstringwithUTCoffsettoadatetimeobject[duplicate](1个回答)关闭7年前。我正在尝试使用以下代码将ISO转换为datetime:dt=datetime.datetime.strptime("2013-07-23T15:10:59.342107+01:00","%Y-%m-%dT%H:%M:%S.%f%z")我收到以下错误:'z'isabaddirectiveinformat'%Y

kotlin - 处理这种情况的最佳方法是 "smart cast is imposible"

我想知道处理这种情况的最佳方法是什么classPerson(varname:String?=null,varage:Int?=null){funtest(){if(name!=null&&age!=null)doSth(name,age)//smartcastimposible}fundoSth(someValue:String,someValue2:Int){}}调用doSth方法并确保name和age为ntnull的最简单方法是什么?我正在寻找一些简单的东西,比如我会简单地使用let的可变场景name?.let{doSth(it)} 最佳答案