草庐IT

key_value

全部标签

swift - 如果存在某种类型的 child ,如果我想获取父 key ,我应该调用什么方法?

这是我的Firebase数据结构2016-10-24Monday":{"types":{"LUNCH":{"typeA":"2","typeB":"1","typeC":"1"},"DINNER":{"typeA":"1","typeB":"2","typeC":"3"}}"2016-10-26Wednesday":{"types":{"LUNCH":{"typeA":"0","typeB":"2","typeC":"3"},"DINNER":{"typeA":"2","typeB":"2"}"2016-10-27Thursday":{"types":{"DINNER":{"typeA

swift - 引用类型 "_": "Cannot assign value of type ' [Value ]' to type ' _ ?'" 的错误

我正在尝试合并两个Dictionary对象。当它们都有一个key的value时,我希望第二个Dictionay的值覆盖第一个,但有几个异常(exception):当两个值都是Dictionary对象时,我希望使用相同的递归方法合并它们。当两个值都是Array对象时,我希望将它们连接起来。我的代码如下:extensionDictionarywhereKey:Hashable,Value:AnyObject{funcmerge(withsecond:[Key:Value])->[Key:Value]{varresultDictionary=selffor(key,value)insecon

ios - 使用来自 JSON swift4 的 key 解码结构

使用Swift4的Encoder&Decoder协议(protocol)和JSONDecoder我如何初始化类型为Codeable的结构使用来自给定JSON的键。即鉴于下面的JSON,我希望只使用results来初始化Example{"boolean":true,"number":123,"results":{"a":"b","c":"d","e":"f"},"string":"HelloWorld"}structExample:MDB,Codeable{vara:Stringvarb:Stringvarc:String}publicstaticfuncinitalize(json:D

ios - 如何使用带椭圆曲线 key 的 SecKeyRawSign 进行签名/验证

我在iOS上生成了一个椭圆曲线私钥/公钥对,并将它们存储到安全飞地内的钥匙串(keychain)中。我想用这些key签署/验证消息。所以,这是我使用SecKeyCreateSignature签署消息的代码。varerror:Unmanaged?letsignature=SecKeyCreateSignature(myPrivateKey,.ecdsaSignatureMessageX962SHA512,plainDataasCFData,&error)它运行良好,但SecKeyCreateSignature仅在iOS10中可用。我想至少保持与iOS9的兼容性。所以我搜索了另一种签署消息

json - JSON 输出不包含键 : "value"

我在下面的Swift代码中遇到了JSON解析问题。我收到的错误表明我的JSON输出不包含键value。我的代码:Alamofire.request(url,method:.get,headers:headers).responseJSON{(response)->VoidinletjsonValue=response.result.valueas!NSDictionaryifletbpArray=jsonValue["value"]as?[NSDictionary]{forresultsinbpArray{...}问题:此转换不起作用:ifletbpArray=jsonValue["v

ios - 如何在 Swift 中适配 Mashape 应用程序 key ?

我尝试使用Mashape的“YodaSpeak”API。我得到了二进制数据,但我不知道如何解析数据。当我尝试打印数据时,收到此消息。“(消息,缺少Mashape应用程序key。转到https://www.mashape.com获取您的key。)”我认为Mashape应用程序key是“jY0bEhHCBpmsh8j1mpA5p11tCJGyp1tok3Zjsn4ubbvNNp5Jt3”。如何在Swift中适配这个键?funcresponse(res:NSURLResponse!,data:NSData!,error:NSError!){letjson:NSDictionary=NSJSO

Swift 2 语法错误 : Cannot call value of non-function type 'Int'

我写了一个函数:extensionString{funcsize()->Int{returncount(self.utf16)}}但它返回一个错误:Cannotcallvalueofnon-functiontype'Int'我该如何解决? 最佳答案 count是swift1.2的方式,在swift2.0中使用myString.characters.count(任何数组都可以这样计算)所以:extensionString{funcsize()->Int{returnself.characters.count}}

ios - 推特搜索 API 1.1 错误 : Could not cast value of type '__NSCFDictionary' to 'NSArray'

此代码用于在Twitter上搜索主题标签,但给出错误提示无法将“__NSCFDictionary”类型的值转换为“NSArray”当我使用以下URL访问我的主页时间线时,相同的代码工作正常https://api.twitter.com/1.1/statuses/home_timeline.jsonfuncgetTimeLine(){letaccountType=account.accountTypeWithAccountTypeIdentifier(ACAccountTypeIdentifierTwitter)self.account.requestAccessToAccountsWi

ios - fatal error : unexpectedly found nil while unwrapping an Optional value (lldb)

我在Swift中使用UIViewController,但当我尝试保留数据并尝试检索它以返回应用程序时,我得到了它。importUIKitclassViewController:UIViewController{@IBOutletvarlinefields:[UITextField]!funcdataFilePath()->String{letpaths=NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory,NSSearchPathDomainMask.UserDomainMask,true

ios - 错误 : 'Cannot call value of non-function type' on Swift 3

以下代码的第二行和第三行适用于swift2.3,自从我更新到swift3后,我一直收到错误消息无法调用非函数类型的值'Any?!'对于他们两个:letdic=tryJSONSerialization.jsonObject(with:data!,options:JSONSerialization.ReadingOptions.mutableLeaves)as!NSDictionaryletlat=((((dic["results"]asAnyObject).value(forKey:"geometry")asAnyObject).value(forKey:"location")asAny