草庐IT

avcodec_decode_video

全部标签

json - swift 可编码 : Decode different array of items with same root objects

我目前正在尝试解码如下所示的JSON:{"result":{"success":true,"items":[{"timeEntryID":"1","start":"1519558200","end":"1519563600","customerName":"Test-Customer","projectName":"Test-Project","description":"Entry1",},{"timeEntryID":"2","start":"1519558200","end":"1519563600","customerName":"Test-Customer","project

ios - 如何在 Swift 4 中将 Encodable 或 Decodable 作为参数传递?

我正在学习JSONParsing。我按照教程进行操作,得到的是:guardleturl=URL(string:"http://localhost/test-api/public/api/register")else{return}varrequest=URLRequest(url:url)request.httpMethod="POST"letnewUser=User.init(name:self.collectionTF[0].text,email:self.collectionTF[1].text,password:self.collectionTF[2].text)do{letj

ios - 如何在 Swift 中使用 Decodable?

我在我的项目中使用免费日期API。我正在使用Decodable来解析JSON数据。我在这里创建了我的结构:-structjsonStruct:Decodable{varmessage:Bool?vardata:[dateData]}structdateData:Decodable{varquarter:Int?varday:String?varmonth:String?}这是我使用解码器的代码:-letjsonUrlString="https://api.lrs.org/random-date-generator?lim_quarters=40&source=api-docs"guar

iOS swift : How to post a video to twitter with TwitterKit?

我还没有找到关于SO的相关和最新的答案。这是我目前正在使用的代码,所有请求都得到了正确处理,但没有发布视频?ifletuserID=Twitter.sharedInstance().sessionStore.session()?.userID{varclient=TWTRAPIClient(userID:userID)lettext:String="TestingVideo"letvideoLength:String="\(self.video.length)"print(videoLength)varinitError:NSError?varmessage=["status":tex

swift 3 : How to catch error if NSCoder decodeX function decodes wrong value type?

Swift3改变了NSCoder的工作方式。正如其他SO问题所提到的,要解码Int或Bool等值类型,您必须使用特定函数。例如,decodeInteger用于解码Int值,如下所示:letvalue=decodeInteger(forKeykey:TestKey)但是,如果decodeInteger返回的值是String或Bool或Int以外的值怎么办?或者如果TestKey实际上映射为空,因为它包含错误的key数据怎么办?如何优雅地捕获这些错误? 最佳答案 在非整数键上使用decodeInteger会引发异常。遗憾的是,这是一个S

json - 如何使用 Decodable 协议(protocol)将此 JSON 转换为 Swift 结构?

注意:这个问题我已经看过了->HowdoIusecustomkeyswithSwift4'sDecodableprotocol?但它没有解释如何编码/解码枚举这是我想要的结构:structMyStruct:Decodable{letcount:PostType}enumPostType:Decodable{casefast(value:Int,value2:Int)caseslow(string:String,string2:String)}现在我知道我希望我的结构看起来如何,问题是:我不知道init函数在PostType枚举中应该是什么样子。我使用下面的代码来帮助我快速构建JSON。

swift - 字符串字典 :Any does not conform to protocol 'Decodable'

这个问题在这里已经有了答案:Fatalerror:DictionarydoesnotconformtoDecodablebecauseAnydoesnotconformtoDecodable(2个答案)关闭4年前。我正在尝试实现一个Decodable来解析json请求,但json请求在对象内部有一个字典。这是我的代码:structmyStruct:Decodable{letcontent:[String:Any]}enumCodingKeys:String,CodingKey{casecontent="content"}但是我收到了这个错误:类型“MyClass.myStruct”不符

ios - 如何在 init 中捕获错误(来自解码器 :Decoder) from a Codable struct?

letjsonString="""{"name":1,"gender":"male",}"""structPerson:Codable{varname:Stringvargender:Stringpublicinit(fromdecoder:Decoder)throws{do{letcontainer=trydecoder.container(keyedBy:CodingKeys.self)name=trycontainer.decode(String.self,forKey:.name)gender=trycontainer.decode(String.self,forKey:.ge

ios - NSGenericException,原因 : [AVCapturePhotoOutput capturePhotoWithSettings:delegate:] No active and enabled video connection

我在尝试运行我的应用程序并拍摄照片时不断收到上述错误消息。我是编程新手,所以如果有人能提供帮助那就太棒了。这是我的代码importUIKitimportAVFoundationimportFirebaseclassCameraViewController:UIViewController,AVCapturePhotoCaptureDelegate,UITextViewDelegate,UITextFieldDelegate{@IBOutletweakvarcameraView:UIView!@IBOutletweakvarcancelButton:UIButton!@IBOutletw

iOS Swift : Trying to use write image buffer to construct video, 未调用 finishWritingWithCompletionHandler。输出视频包含零字节

我试图只从静态图像中写入两帧来构建视频。我一直在绕过时间参数。似乎最后一步finishWritingWithCompletionHandler从未被调用(完成写入......永远不会输出)。只创建了一个零字节.mp4视频。并且没有发生错误。不知道为什么。这是我使用的代码:funccreateBackgroundVideo(CompletionHandler:(path:String)->Void){varmaybeError:NSError?letfileMgr=NSFileManager.defaultManager()letdocDirectory=NSHomeDirectory(