草庐IT

hardcoded_Value

全部标签

ios - Firebase 的 snapshot.value 转换为 Bool 突然返回 nil

所以我的代码运行得非常好,但今天当我尝试将Firebase的snapshot.value转换为Bool时它返回nil。我根本没有对代码进行任何更改。但是,如果我将它转换为一个字符串,它就可以正常工作(因为?字符串返回“true”)。在我转换为[String:Bool]的另一个地方出现了同样的问题。与之前不同的是,我今天安装了Xcode10beta3(也安装了Xcode9.4)。两个Xcode版本都返回nil。这是代码:ifletcurrentUserId=Auth.auth().currentUser?.uid{Database.database().reference().child

ios - Swift 4 : Variable 'value' inferred to have type 'Void' , 这可能是意想不到的?

我正在尝试将存储在firebase存储中的图像的下载URL保存在数据库中。我看过here,和here,但是我收到以下错误:Cannotconvertvalueoftype'Void'totype'[String:String]'incoercion这发生在下面指示的行上:storageRef.downloadURL{(url,error)inguardletdownloadURL=urlelse{//Uh-oh,anerroroccurred!return}//databaseintegrationletref=Database.database().reference()letuse

swift - 从 Firebase Firestore - Swift 4 获取当前用户的值(value)

这是我的第一个问题,希望你能帮助我。我一直在尝试获取当前用户登录我的应用程序的特定路径。我现在真的不知道我做错了什么,所以我会在这里粘贴我的代码。funcuserRoleListener(){guardletuser=Auth.auth().currentUserelse{return}.Firestore.firestore().collection("users").document("sjbD5SvKTYHWBLhCqojs").getDocument{(snapshot,error)inifletdata=snapshot?.data(){guardletisAdmin=dat

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

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

objective-c - 一些for循环的问题 - - "Cannot subscript a value of type ' Double' with an index of type 'int' "errors

我在有索引的地方收到很多“无法使用‘int’类型的索引下标‘Double’类型的值”错误?阵列?像这样此代码取自Obj-C,并尽可能翻译成Swift,但我不熟悉某些语法。我清理了for循环,但一些Obj-C语法仍然存在。你能帮我清理/重构我的代码吗?importUIKitimportFoundationimportAVFoundationletminFramesForFilterToSettle=10enumCurrentState{casestatePausedcasestateSampling}classViewController:UIViewController,AVCaptu

ios - NSDictionary, (key :AnyObject, value:AnyObject) 没有成员名下标

我正在为IOS学习swift,当我在youtube上做巡回演出时(Swift:SkipWilson的Swift:使用外部数据库和API)对于外部数据库,我找到了部分:service=PostService()service.getPosts{(response)inself.loadPosts(response["posts"]!asNSDictionary)}funcloadPosts(posts:NSDictionary){forpostinposts{varid=(post["Post"]["id"]asString)vartitle=post["Post"]!["title"]

ios - swift : How can i obtain a documented value for UIImagePickerControllerMediaType

目前要知道什么是媒体类型,如果用户选择图像到相机胶卷或拍摄新照片,我将获得“public.image”,如果是电影,则获得“public.movi​​e”。我阅读了UIImagePickerControllerMediaType的Apple文档,我看到了这个:letUIImagePickerControllerMediaType:String常量UIImagePickerControllerMediaTypeSpecifiesthemediatypeselectedbytheuser.ThevalueforthiskeyisanNSStringobjectcontainingatype