草庐IT

move_member

全部标签

ios - 初始化变量 : 'self' captured by a closure before all members were initialized

我在初始化自定义类时遇到问题。当初始化更新属性的类时,我需要在一些数据上设置一个观察者。最初,属性可以为空,这就是我在启动时设置它们的方式。但是,Xcode仍然会抛出“在所有成员初始化之前由闭包捕获的‘self’”错误。这是代码的简化版本。classFoo{init(){self.usersRef=ref.child("users")self.usersRef.observe(DataEventType.value,with:{(snapshot)in//snapshoterrorchecking//usersis[String]self.users=users})}privateva

IOS FoodTracker 教程 : Value of tuple type '()' has no member 'path'

我正在完成IOSSwift教程“FoodTracker”,但是有一个错误我可以找到解决方案,但我不明白哪里出了问题以及如何解决它:错误:Valueoftupletype'()'hasnomember'path'此错误在以下代码中针对变量“Meal.ArchiveUrl.path”显示。我的代码,在MealtableViewController(相当于IOS教程):privatefuncsaveMeals(){letisSuccessfulSave=NSKeyedArchiver.archiveRootObject(meals,toFile:Meal.ArchiveUrl.path)if

ios - 找不到成员(member)下标

我正在尝试执行以下代码并收到错误Couldnotfindmember'subscriptonXcode6varb:[[Float]]=[[1,2]]vari2=0//secondtolastcontrolpointvarpointIm1=CGPoint(x:0.0,y:0.0)varpointI=CGPoint(x:0.0,y:0.0)varpointIp1=CGPoint(x:0.0,y:0.0)varpx:Float=b[0][0]*Float(pointIm1.x)+b[0][0]*Float(pointI.x)+b[0][0]+b[0][0]*Float(pointIp1.x)

ios - Q re : cleaning up an an array without moving indexes

我正在尝试完成HackerRank'sAbbreviationchallenge在Swift中。我正在尝试确定给定的缩写是否可以用给定的字符串形成的诗人物理学。给你一个字符串和一个他们想用它组成的缩写。曲线球是您只能删除字符或更改它们的大小写...您不能交换它们的索引。我能够完成他们给我的字符串的大部分验证和清理,但我被困在只能删除字符但不能交换索引的部分。letabbrArray=abbreviation.characters.map({String($0)})varmatchingCharArray=capitalizedInputArray.filter({abbrArray.c

xcode - 如何在 Xcode 6.3.1 中模拟 'moving' 位置

尝试在Swift中训练时提取一些移动位置数据,而模拟器现在只有固定位置(伦敦、纽约等)。我认为您曾经能够模拟通过汽车或自行车的移动。是否可以模拟移动位置?谢谢 最佳答案 要模拟移动位置,请转到在iOS模拟器设置中选择下面的菜单(确保您的map首先显示在模拟器上然后执行以下操作)。调试->位置->选择“CityBicycleRide”或“FreewayDrive” 关于xcode-如何在Xcode6.3.1中模拟'moving'位置,我们在StackOverflow上找到一个类似的问题:

arrays - iOS swift : How to find unique members of arrays of different types based on specific attributes

目标:我有两个不同的类,以及两个包含每个类成员的数组。使用Swift2.0,我想根据每个类的特定属性找到一个数组与另一个数组相比的唯一成员。示例:classA{varname:Stringinit(name:String){self.name=name}}classB{vartitle:Stringinit(title:String){self.title=title}}letaArray=[A(name:"1"),A(name:"2"),A(name:"3"),A(name:"4")]letbArray=[B(title:"1"),B(title:"2"),B(title:"5")]

ios - 错误 : Value of type 'String' has no member 'URLByAppendingPathComponent'

我的错误是:“String”类型的值没有成员“URLByAppendingPathComponent”我在这一行中遇到了错误:letsavePath=documentDirectory.URLByAppendingPathComponent("mergeVideo-\(date).mov")我的完整代码://4-GetpathletdocumentDirectory=NSSearchPathForDirectoriesInDomains(.DocumentDirectory,.UserDomainMask,true)[0]vardateFormatter=NSDateFormatter

ios - swift 错误 : Struct 'XX' must be completely initialized before a member is stored to

我正在尝试在Swift中定义AudioStreamBasicDescription。在Objective-C中,我使用了如下代码。AudioStreamBasicDescriptionASBD;ASBD.mSampleRate=8000;ASBD.mFormatID=kAudioFormatLinearPCM;ASBD.mFormatFlags=kAudioFormatFlagsCanonical|kAudioFormatFlagIsSignedInteger|kAudioFormatFlagIsPacked;ASBD.mFramesPerPacket=1;ASBD.mChannels

ios - 自定义 UITableViewCell : Value of type 'UITableViewCell' has no member 'pointsNumber'

我的错误在下面的第一个代码中,在开关的情况2中。cell.pointsNumber.text="toto"Xcodeerror:Valueoftype'UITableViewCell'hasnomember'pointsNumber'我无法访问我的类PerformancesViewCell来填充标签。我的转换不起作用,我的单元格仍然像UITableViewCell而不是PerformancesViewCell。预先感谢您的帮助;)细胞标识符:letthirdCellIdentifier="thirdCell"表格View:functableView(tableView:UITableV

swift - 如何让玩家在路径中 move 到另一边?

我希望当触摸开始时玩家(红色圆圈)move到圆形路径的另一侧。我已经让玩家跟随一条路径,但我还没有在互联网上找到我的问题的答案。overridefuncdidMoveToView(view:SKView){player=SKSpriteNode(imageNamed:"circulo")player.position=CGPoint(x:self.frame.width/2,y:self.frame.height/2-170)player.color=colorGrisplayer.colorBlendFactor=1player.size=CGSize(width:25,height