草庐IT

convert_it

全部标签

swift - watch 操作系统 2 : Is it possible to get bluetooth signal strength of connectivity between paired iPhone and Apple Watch?

标题是不言自明的。我尝试过CoreBluetooth,但我没有将AppleWatch视为连接的外围设备。 最佳答案 这是可能的。使用retrieveConnectedPeripherals(withServicesserviceUUIDs:[CBUUID])->[CBPeripheral]。您需要为服务UUID指定蓝牙GATT特性。我用了ContinuityUUID:“D0611E78-BBB4-4591-A5F8-487910AE4366”。该函数返回一个CBPeripheral对象,然后您可以使用connect(_periphe

ios - `Protocol can only be used as a generic constraint because it has Self or associated type requirements` 问题

我正在尝试生成一个符合协议(protocol)Protocoling的ViewModel,该协议(protocol)是通用的,并且具有关联的类型。有几个ViewModel符合协议(protocol),所以我正在尝试为viewModel创建一个工厂。我在Swift中遇到了以下错误:Protocol只能用作泛型约束,因为它有Self或关联类型要求示例代码:protocolProtocoling{associatedtypemodulingTypevardata:modulingType{get}}enumMyTypes{casemyNamecasemyAddress}classNameVi

vue3 setup + ts + vite 项目问题解决:Cannot find module ... or its corresponding type declarations.(ts2307)

昨日我尝试使用vue3setup+ts+vite进行vue3项目的实现,遇到此问题:Cannotfindmodule...oritscorrespondingtypedeclarations.(ts2307)文件报错类型以及ts官方错误说明:这里以别名"@"为例子://.vue文件importLoginApifrom'@/apis/loginApi';//(ts2307)import{getDate}from'@/utils/date';//(ts2307)//.ts文件importLoginApifrom'@/apis/loginApi';//(ts2307)2307错误Cannotfind

struct - 错误 : 'Int' is not convertible to '@lvalue Float'

给定以下函数:funcgreatestCommonDenominator(first:Int,second:Int)->Int{returnsecond==0?first:greatestCommonDenominator(second,first%second)}还有一个包含以下内容的结构:structFraction{varnumerator:Intvardenominator:Intfuncreduce(){letgcd=greatestCommonDenominator(numerator,denominator)self.numerator/=gcdself.denomina

xcode - 快速 Xcode 单元测试 : Cannot convert value of type "Person" to expected argument type "Person"

我正在尝试编写一个单元测试类来测试我的自定义类。当我尝试使用自定义对象作为输入变量调用自定义类中的方法时,我得到:'无法将类型“Person”的值转换为预期的参数类型“Person”。“Person”是从NSManagedObject继承的类,输入对象是从中创建的。我对采用其他值类型的其他方法没有问题。该方法工作正常。测试类是唯一提示这个的。这是错误还是限制?有什么建议可以让我更深入地研究这个问题吗? 最佳答案 我之前遇到过这个问题。事实证明,被测系统(在我的例子中是调用对象的服务;对于您的示例,可能是PersonService)没

swift - iOS Swift 错误 : 'T' is not convertible to 'MirrorDisposition'

我正在尝试为Array类型创建一个扩展方法,以允许从数组中删除一个项目extensionArray{funcremove(item:AnyObject){forvari=self.count-1;i>=0;i--{ifself[i]==item{self.removeAtIndex(i)}}}}关于测试条件ifself[i]==item,我收到以下错误:'T'isnotconvertibleto'MirrorDisposition'我尝试过很多不同的东西,包括:使用泛型:remove(item:T)使用===运算符,它只给出错误'T'doesnotconformtoprotocol'A

ios - swift : show searchbar when scroll up and hide it when scroll down

我是Ios开发的新手,我在导航项中添加了一个Searchbar我想要实现的是当我向上滚动tableview我想隐藏Searchbar并在向下滚动时显示它类似于iPAD/Iphone上的safari效果,向下滚动时隐藏地址栏,向上滚动时显示地址栏letsearchController=UISearchController(searchResultsController:nil)searchController.searchResultsUpdater=selfsearchController.obscuresBackgroundDuringPresentation=falsenaviga

swift - '[任务] ?' is not convertible to ' 可选<[任何]>'

我做了扩展extensionOptionalwhereWrapped==[Any]{varisNilOrEmpty:Bool{get{ifletarray=self{returnarray.count==0}else{returnfalse}}}}然后我尝试这样使用它iffetchedResults.fetchedObjects.isNilOrEmpty{...}我遇到了错误'[Task]?'isnotconvertibleto'Optional'但是,根据规范Anycanrepresentaninstanceofanytypeatall,includingfunctiontypes.

swift - 自更新到 Swift 1.2 以来,字典现在给出错误 'not convertible to BooleanLiteralConvertible'

我刚刚开始了解Swift-然后Swift1.2来了(打破了我的工作代码)!我有一个基于NSHipster-CGImageSourceCreateThumbnailAtIndex中代码示例的函数.我以前的工作代码是:importImageIOfuncprocessImage(jpgImagePath:String,thumbSize:CGSize){ifletpath=NSBundle.mainBundle().pathForResource(jpgImagePath,ofType:""){ifletimageURL=NSURL(fileURLWithPath:path){ifletim

swift - Xcode 8.1 Swift 3 错误 : cannot convert value of type 'String' to expected argument type 'UnsafeMutableRawPointer'

包含varsceneData代码的行给出了一个错误,显然是因为“路径”字符串。有谁知道如何解决这个问题?谢谢!extensionSKNode{classfuncunarchiveFromFile(_file:String)->SKNode?{ifletpath=Bundle.main.path(forResource:file,ofType:"sks"){varsceneData=Data(bytesNoCopy:path,count:.DataReadingMappedIfSafe,deallocator:nil)!vararchiver=NSKeyedUnarchiver(forR