草庐IT

EXC_GUARD

全部标签

ios - EXC_BAD_ACCESS 尝试编码 Codable-conformant 类的子类时

我一定是个白痴之类的,但我已经连续第三天摸不着头脑了,无法弄清楚我打算在我的Swift程序中编码一些JSON数据的意图出了什么问题......情况是这样的:我有两个类如下:classNode:Codable{//Nothinginhere}和classShape:Node{//Nocodeheretoo}然后,我尝试按如下方式对子类进行编码:do{letencodedData=tryJSONEncoder().encode(Shape())}catch{print(error)}这就是我添加到一个空的单View应用程序项目中的所有内容。当我运行它时,出现“Thread1:EXC_BAD

ios - Swift 的 NSCoding 中的 EXC_BAD_INSTRUCTION

funcencodeWithCoder(aCoder:NSCoder!){aCoder.encodeObject(title.bridgeToObjectiveC(),forKey:"title")aCoder.encodeObject(self.artist.bridgeToObjectiveC(),forKey:"artist")}init(coderaDecoder:NSCoder!){NSLog("title:%@",aDecoder.decodeObjectForKey("title")asNSString);//我有一个符合上述NSCoding的NSObject,但是当它初

azure - 在 iOS 上使用带有 swift 的 Azure 移动服务框架的问题 - EXC_BAD_ACCESS 同时将表记录保存到类属性

我无法通过SwiftiOS应用程序使用Azure移动服务。我认为这个问题与对self.items属性的闭包访问有关。我已经尝试从github构建dev分支,但我收到同样的错误。errorEXC_BAD_ACCESS(code=1,address=0xa0)这是我的代码:importUIKitclassAVZItemsTableViewController:UIViewController,UITableViewDataSource,UITableViewDelegate{leturl="https://XYZ.azure-mobile.net/"letkey="XYZ"lettable

inheritance - 在 Swift 中使用泛型、协议(protocol)和继承创建对象时出现 EXC_BAD_ACCESS

此代码会产生EXC_BAD_ACCESS(即使在playground中)。(我简化了我的代码以便更好地理解。)准备://Playground-noun:aplacewherepeoplecanplayprotocolEmptyInit{init();}classFirstBase{}classSecondBase:EmptyInit{requiredinit(){}}classA:FirstBase,EmptyInit{requiredoverrideinit(){}}classB:SecondBase,EmptyInit{requiredinit(){}}很明显,您可以像这样创建A和

swift - 如何调试 "EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)"Swift 错误?

我需要以下代码才能运行。letillinois=College(name:"UniversityodIllinois",location:"Urbana-Champaign",numberOfStudents:35000,image:UIImage(named:"Default")!)letmissouri=College(name:"UniversityofMissouri",location:"Columbia",numberOfStudents:34658,image:UIImage(named:"MissuouriImage")!)letiowa=College(name:"U

iOS11 在 AVPlayerItemTrack.assetTrack.mediaType (Thread 1 : EXC_BAD_ACCESS (code=1, address=0x0) 上崩溃

我像这样从AVPlayerItem观察轨道属性的键值:overridefuncobserveValue(forKeyPathkeyPath:String?,ofobject:Any?,change:[NSKeyValueChangeKey:Any]?,context:UnsafeMutableRawPointer?){ifcontext==&PlayerItemObserverContext{[...morecode...]}elseifkeyPath==#keyPath(AVPlayerItem.tracks){ifletplayerItem=self.playerItem{fort

ios - Swift 中的 UIWebView : exc_bad_access

我的带有UIWebView的Swift应用在尝试获取当前URL时因exc_bad_access而崩溃。它也仅在某些情况下崩溃(通常取决于用户在该UIWebView中执行的操作)。尝试加载代码中提供的url,然后点击取消。如果我不从UIWebViewDelegate协议(protocol)实现方法,它永远不会崩溃。classAuthViewController:UIViewController,UIWebViewDelegate{@IBOutletvarauthWebView:UIWebViewinit(nibNamenibNameOrNil:String?,bundlenibBundl

ios - Swift:将 AppDelegate 实例作为类函数导致线程 1:EXC_BAD_INSTRUCTION

我想从我的AppDelegate中的classfunc获取我的AppDelegate引用。为什么会抛出Thread1:EXC_BAD_INSTRUCTION?classfuncgetDelegate()->AppDelegate{returnUIApplication.sharedApplication().delegateas!AppDelegate}我也曾尝试将其移动到另一个实用程序类并作为常规func,但遇到了同样的崩溃。有没有一种方法可以将AppDelegate作为classfunc而不必编写letappDelegate=UIApplication.sharedApplicat

Swift 语言 : how to continue after a guard statement?

为什么continue标记错误:continueisonlyallowedinsidealoopprivatefuncaddToUnloadedImagesRow(row:Int,forLocation:String!){guardunloadedImagesRows[forLocation]!=nilelse{unloadedImagesRows[forLocation]=[Int]()continue}unloadedImagesRows[forLocation]!.append(row)}我该如何解决? 最佳答案 contin

swift - 是否有 guard return 的简写形式?

有没有办法让guard自动返回而不需要每次都写出来,例如:guardleturl=self.webView.urlelse{return}guardletcomponentDict=URLComponents(string:url.absoluteString)?.dictelse{return}guardletid=componentDict["v"]else{return}guardletidUrl=URL(string:baseUrl+id)else{return}如果我实际上需要在return之外做一些事情,我会在我的额外处理中包含else{return}位。这不是什么大麻烦,