草庐IT

Failure-while

全部标签

ruby-on-rails - 在 RoR 中,如何从 "Failed to open TCP connection ... (general SOCKS server failure)"错误中恢复?

我正在使用Rails4.2.7。目前我正在像这样通过SOCKS代理请求网页begin...res1=Net::HTTP.SOCKSProxy('127.0.0.1',50001).start(uri.host,uri.port)do|http|puts"launching#{uri}"resp=http.get(uri)status=resp.codecontent=resp.bodycontent_type=resp['content-type']content_encoding=resp['content-encoding']end...rescueOpenURI::HTTPErr

iOS 编程 : Making an arc4_random not repeat itself using a do while loop

这个问题在这里已经有了答案:What'stheBestWaytoShuffleanNSMutableArray?(12个答案)关闭8年前。在此代码中,第二行遍历数组并输出它接收到的内容及其随机数。但有时我会说同样的话两次,就像它会说“Straub”,然后是“Straub”,然后是“Rusher”之类的东西。我试过做一个“dowhileloop”,但我不知道如何在它不重复的地方设置它。顺便说一句,这是一种快速的编程语言。lettypes=["Alex","Straub","Rusher","Graser"]lettype=types[Int(arc4random_uniform(UInt

uitableview - swift - 错误 : unexpectedly found nil while unwrapping an optional value

我一直在用Swift制作应用程序,但我的TableViewController类中一直出现错误。我找不到任何方法来解决此问题并不断收到此错误:overridefunctableView(tableView:UITableView?,cellForRowAtIndexPathindexPath:NSIndexPath!)->UITableViewCell!{letcell:TextTableViewCell=tableView!.dequeueReusableCellWithIdentifier("Cell",forIndexPath:indexPath!)asTextTableView

swift - 从 Parse.com 检索 PFFile 时为 "unexpectedly found nil while unwrapping an Optional value"

我在检索存储在Parse.com中的PFFile时遇到问题letuser=PFUser.currentUser()letuserImageFile=user["profileImage"]asPFFileuserImageFile.getDataInBackgroundWithBlock{(imageData:NSData!,error:NSError!)->Voidiniferror==nil{ifimageData!=nil{letimage=UIImage(data:imageData)self.profileImage.image=image}}}错误从第二行开始。“profi

ios - 在 Swift ios 中使用 vImageBuffer_initWithCGImage 时出现 "fatal error: unexpectedly found nil while unwrapping an Optional value"

我正在使用SwiftiOS8并尝试将UIImage转换为vImage_Buffer以使用Accelerate.framework执行操作。我正在尝试使用vImageBuffer_initWithCGImage进行转换,这是我尝试过的代码:funcinitvImageBufferwithUIImage(image:UIImage)->vImage_Buffer{varCGImg:CGImageRef=sunset.CGImagevarinProvider:CGDataProviderRef=CGImageGetDataProvider(CGImg)varinBitmapData:CFDa

ios - swift - 警告 : Attempt to present * on * while a presentation is in progress

由于这个错误,我无法切换到另一个ViewController。我想在成功扫描二维码后切换到另一个ViewController。2015-01-2717:59:16.093*[5416:1860144]Warning:Attempttopresentonwhoseviewisnotinthewindowhierarchy!我的代码@IBActionfuncbtnQrCode(sender:AnyObject){reader.modalPresentationStyle=.FormSheetreader.delegate=selfreader.completionBlock={(resul

swift - 在 swift 中解析 JSON 抛出 'fatal error: unexpectedly found nil while unwrapping an Optional value'

我正在尝试获取json对象,但无法获取这是我的代码funcloadShots(completion:((AnyObject)->Void)!){varurlString="http://ip.jsontest.com/";letsession=NSURLSession.sharedSession()letshotsUrl=NSURL(string:urlString)vartask=session.dataTaskWithURL(shotsUrl!){(data,response,error)->Voidiniferror!=nil{println(error.localizedDes

while 语句中的 Swift 二元运算符

Swift的新手,小障碍。这段代码letviewH=self.view.frame.size.widthletboxH=viewH/60varcurY=0whilecurY抛出错误“二元运算符 最佳答案 小障碍,小修复。你的问题是curY是一个Int而右边的减法结果是一个CGFloat(什么是width还给你)。因此,您需要做的就是将curY也转换为CGFloat:varcurY=0asCGFloat或者:varcurY:CGFloat=0 关于while语句中的Swift二元运算符,我

swift - 通过按下按钮快速停止 for 或 repeat-while 循环

我需要弄清楚如何停止循环。我尝试了几种不同类型的循环,但最终结果是一样的——在循环进行时无法按下停止按钮。这是我到目前为止所拥有的...varstopButtonPressed=falsevarnumArray=[0,1,2,3,4,5,6,7,8,9]fornuminnumArray{print(num)sleep(2)ifstopButtonPressed{return}}很明显,按下的按钮将stopButtonPressed设置为true,但是同样...循环迭代时无法按下按钮。那么执行此操作的更好方法是什么?编辑@dasblinkinlight好的,所以我可以遵循您所说的逻辑,但

ios - fatal error : unexpectedly found nil while unwrapping an Optional value using AVAudio

我有两个项目,使用相同的代码,但下面一行:player=AVAudioPlayer(contentsOfURL:NSURL(string:fileLocation),error:&error)仅在一个项目中返回此错误:fatalerror:unexpectedlyfoundnilunwrappinganOptionalvalue另一个项目运行没有错误。我正在尝试播放声音。importUIKitimportAVFoundationclassViewController:UIViewController{varplayer:AVAudioPlayer=AVAudioPlayer()over