草庐IT

from_int

全部标签

ios - iBeacon iOS 10 : Can device scan for and receive advertisements from other peripheral devices?

这里是全新的。Tl;dr:一个iOS设备可以发布一个CB广告(CBAdvertisementDataServiceUUIDsKey和/或CBAdvertisementDataLocalNameKey),另一个iOS设备可以扫描它吗?我相信我的问题是基于iOS的更高版本中对CoreBluetooth和CoreLocation的弃用和更改而提出的。另外,目前,我仅指“前台”操作。根据我阅读和测试的内容,外围设备可以使用CL传输信标区域(唯一的邻近UUID、主要和次要(但值得注意的是没有“标识符”))。使用CB,外围设备还可以“通告”两个少量的额外数据中的任何一个:CBAdvertiseme

ios - 无法将类型 '[String]' 的值转换为预期的参数类型 'String' : while appending arrays to get data from Fireabse in table view cell

在快照中追加数组时出错。我想从快照中的这些数组EngNames、UrNames和cakeImages中检索所有值,以便这些值可以显示在表格View单元格上。但是我可以从Firebse检索CakeRateLabel和EngNameLabel的所有值,但我只想检索所有cakeRatelabel来自firebase的rate值和EngNames,UrNames和cakeImages我想要的数据的其余部分分别从Assets中定义的数组和图像中检索本地。帮助我完成这项工作,我们将不胜感激。Firebase结构ViewControllerTestTabelViewControllerimportU

swift - 如果在 Swift 中是整数,则将 Double 显示为 Int

我正在尝试编写一种方法来检查Double是否以.0结尾,而不是其他任何结尾。因此,例如检查它是2.0还是2.12345。如果它是2.0,那么我希望它只显示2,但如果它是2.12345,则显示2.12345。我想写一个将Double作为参数并返回Int的func,但如果输入结果是.12345,它就无法返回它。所以我想知道我的想法是否适用于调整,或者是否有非常相似的方法。我在想也许返回类型可以同时是Int和Double,但我不知道它是如何工作的。这是我目前的情况privatefunccheckIfWholeNumber(displayedDouble:Double)->Int{ifdisp

swift - 查找 [String : [Int]] Swift dictionary 中的最大数字

我是Swift的新手。我在使用此代码时遇到错误,并且在此站点上找不到任何答案。我打印最大数量,但我想打印最大数量的种类。letinterestingNumbers=["Prime":[2,3,5,7,11,13],"Fibonacci":[1,1,2,3,5,8,13],"Square":[1,4,9,16,25,36]]varlargestNumber=0for(kind,numbers)ininterestingNumbers{forxinnumbers{foryinkind{ifx>largestNumber{largestNumber=x}}}}print("thelarges

ios - 错误 : Invalid conversion from throwing function of type '(_) throws -> ()' to non-throwing function type '(DataSnapshot) -> Void'

这是我的代码:funcloadData(){ref.child(currentUserID!).observe(.childAdded){(snapshot)inletsnapshotValue=try?snapshot.valueas?[String:AnyObject]ifletitem=tryTableViewModel(id:snapshot.key,likeLabel:self.likeLabel,playLabelString:self.playLabelString,json:snapshotValue){self.items.append(item)}self.tabl

ios - AudioKit,AKPlayer : How to play from Samples, 不是时间

我目前正在使用FDWaveFormView非常成功地显示代表我从AKMicrophone或AKAudioFile录制的音频的波形。我成功地突出显示了波形中的特定区域,FDwaveForm返回了音频文件中的一系列样本。我现在的问题是我无法在AKPlayer中找到合适的方法来让我从开始样本播放到结束样本。我注意到AKSamplePlayer现在已被弃用,但它确实有一个方法:play(from:Sample,to:Sample)我的猜测是我可以做一些数学运算来将样本位置转换为时间(作为AKPlayer中规定的Double),但是我还没有找到执行此操作的适当数学或函数,有什么提示吗?为了清楚地

ios - 基础:为什么 Int64.max 和 Double(Int64.max) 在 Swift iOS SDK 中打印 2 个完全不同的值

这是我的Swift代码print("\(Int64.max)")print("\(Double(Int64.max))")它产生以下输出92233720368547758079.223372036854776e+18为什么两者的值完全不同9.223372036854776e+18-9223372036854775807=193仅供引用 最佳答案 您在输出中看到的Double的值只是一些有效数字的近似值。我们可以通过String(format:)看到更多有效数字print(String(format:"%.1f",Double(Int

swift - 收到 fatal error : Double value cannot be converted to Int because it is either infinite or NaN

该代码用于播客应用。importAVKitextensionCMTime{functoDisplayString()->String{lettotalSeconds=Int(CMTimeGetSeconds(self))letseconds=totalSeconds%60letminutes=totalSeconds/60lettimeFormatString=String(format:"%02d:%02d",minutes,seconds)returntimeFormatString}}选择要播放的播客时失败...导致音频播放但应用程序卡住,直到重新启动。编辑:错误发生在行lett

swift - 乘以 Swift Ints 时出错

这里是新的Swift爱好者!我正在关注ReyWenderlich的CandyCrushtutorial并在将两个Int值相乘时出错。我知道Swift是严格类型化的,这就是原因吗?我不允许在Swift中这样做吗?请注意我遇到问题的error注释。非常感谢在正确方向上提供的任何帮助!classArray2D{letcolumns:Intletrows:Intletarray:Arrayinit(columns:Int,rows:Int){self.columns=columnsself.rows=rowsarray=Array(count:rows*columns,repeatedValu

ios - 更新 Int32 类型的 CoreData 属性

我想获取核心数据属性的值,在获取此对象/值后我想更新它。这是我的代码:varnumberOfChanges:Int32?numberOfChanges=theme.valueForKey("numberThemeChanged")asInt32varnewValueThemeChanges:Int32?newValueThemeChanges=numberOfChanges+1theme.setValue(newValueThemeChanges,forKey:"numberThemeChanged")我收到以下错误:Type'Int32'doesnotconformtoprotoco