草庐IT

member_number

全部标签

ios - 'UITableViewCell ?' does not have a member named ' 文本标签'

我四处寻找这个问题的答案,但没有成功。我基本上是在按照教程创建一个简单的待办事项应用程序,许多其他人正在评论与下面相同的错误。作者暂时还没有解决办法。任何帮助,将不胜感激。我收到错误:'UITableViewCell?'没有名为“textLabel”的成员到目前为止,这是我的代码:importUIKitclassViewController:UIViewController,UITableViewDelegate,UITableViewDataSource{//tellsiphonewhattoputineachcellfunctableView(tableView:UITableVi

ios - "Ambiguous reference to member map"来自具体类型

这是我的代码。它使用来自CoreBluetooth的CBUUID。让我们假设v的转换是有效的。importUIKitimportCoreBluetoothfuncconvert(v:AnyObject)->[String:String]{return(vas![CBUUID:NSData]).map{(uuid,data)in(uuid.UUIDString,NSString(data:data,encoding:NSUTF8StringEncoding)??"")}}想法是通过为CBUUID调用CBUUID.UUIDString并通过调用适当的NSString构造函数来获取字典的字符

ios - 错误 : Type 'String!' has no member 'video'

importUIKitimportAVKitclassViewController:UIViewController{overridefuncviewDidLoad(){super.viewDidLoad()//startcameraletcaptureSession=AVCaptureSession()guardletcaptureDevice=AVCaptureDevice.default(for:.video)else{return}guardletinput=try?AVCaptureDeviceInput(device:captureDevice)else{return}ca

ios - 错误 : Instance member cannot be used on type 'ViewController'

这个问题在这里已经有了答案:Instancemembercannotbeusedontypeofcustomclass(3个答案)关闭4年前。我正在按照斯坦福类(class)的在线讲座制作浓度游戏,但我的代码的一部分出现错误。我收到错误消息“实例成员‘cardButtons’不能用于类型‘ViewController’”,但代码似乎适用于讲师。有人可以帮我解决这个问题吗?这是代码的一部分。第4行出现错误importUIKitclassViewController:UIViewController{@IBOutletvarcardButtons:[UIButton]!lazyvargam

swift 3 : How to Calculate Random Number with Favor Towards A Bias

假设我正在计算1到100之间的随机数。我希望它选择的数字是随机的,但我可以设置一个更有可能选择中心的位置。因此,如果我做随机样本让我们说一千次,那么中心数字被更频繁地选择会有明显的相关性。它选择中心的数量应该基于我可以在didHitChanceOf函数中设置的数字。执行此操作的最佳方法是什么?我目前的代码没有做到这一点,甚至是随机性的当前无偏随机数代码(Swift3)extensionInt{staticfuncrandom(range:ClosedRange)->Int{varoffset=0ifrange.lowerBoundBool{letrandom=Int.random(ra

iOS swift : Value of type 'NotificationCenter' has no member 'publisher'

我正在尝试将新的Combine框架与NotificationCenter一起使用,正如Apple在这段视频中所解释的那样:https://developer.apple.com/videos/play/wwdc2019/721/您可以在幻灯片21中找到它。看来我的项目没有读取Combineframeworkapi。importCombineimportFoundationlettrickNamePublisher=NotificationCenter.default.publisher(for:.newTrickDownloaded)我收到这个错误:“NotificationCente

swift 4 : Formatting number's into friendly K's

目前正在开发一个对我来说非常有用的简单功能..例如:如果我有1000,它会打印出1.0K,或者1,000,000它将是1M,直到这里一切正常,Whatifiwantedtoturn1,000,000,000into1B?我尝试了以下->funcformatPoints(from:Int)->String{letnumber=Double(from)letthousand=number/1000letmillion=number/1000000letbillion=number/1000000000ifmillion>=1.0{return"\(round(million*10)/10)

ios - swift 4 : Array for all types of Ints and Floating point numbers

我有一个程序可以处理所有类型的Ints和Floating指针值类型有没有一种方法可以创建数组来保存所有这些值?我尝试通过协议(protocol)来做到这一点,并用它们扩展Int和Double但没有成功,因为Swift中的协议(protocol)均等性限制(或类似的东西)protocolArrayStructValue:Comparable,Equatable{}extensionDouble:ArrayStructValue{}extensionInt:ArrayStructValue{} 最佳答案 如果你想在一个数组中有两种不同的

ios - 警告 : Unexpected version number in 'available' attribute for non-specific platform '*'

我有这段代码:@available(*,deprecated:3.0,message:"Useactivate().")publicfuncinstall(){self.activate()}自从我升级到swift5和xcode10.2之后,我收到以下警告:Unexpectedversionnumberin'available'attributefornon-specificplatform'*'并修复:Replace':3.0'with''这个警告是什么?它说什么? 最佳答案 documentation指出星号不能与Swift版本

macos - swift 错误 "Immutable value only has mutating members"

编译以下Swift代码时(在Sample.swift中):importCocoaclassSample{funcdoSomething(){varstringArray=Array()stringArray.append("AAA")addToString(stringArray)stringArray.append("CCC")}funcaddToString(myArray:Array){myArray.append("BBB")}}我在“myArray.append("BBB")”行收到以下错误:Immutablevalueoftype'Array'onlyhasmutating