草庐IT

member_function

全部标签

swift - 'SKView ?' does not have a member named ' 边界'

我最近遇到一个代码错误,想解决这个问题。它是快速编码的,我希望你们能帮我解决这个问题。错误说:“SKView?”没有名为“边界”的成员如果你能帮助我,因为这是我的第一个swift应用程序,我会永远爱你:)这里是这个问题的“标题”的代码。overlay=SKSpriteNode(color:UIColor.grayColor(),size:self.view.bounds.size) 最佳答案 SKView?没有bounds类型的属性(注意?),但是SKView!可能。在第一个示例中,您遇到错误的那个示例中,您没有隐式解包可选。为此,

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 - 错误 : '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

ios - SkSpriteNode没有成员(member)中心

我有一个名为“Ghost”的SKSpritenode,我想在图像外部添加一个脉冲外观。但是我收到一条错误消息,说它没有中心,我不确定如何解决这个问题,请帮忙。funcaddPulse(){letpulse=Pulsing(numberOfPulses:.infinity,radius:110,position:Ghost.center)pulse.animationDuration=1.0pulse.backgroundColor=UIColor.blue.cgColorself.view.layer.insertSublayer(pulse,below:Ghost.layer)}

swift - 为什么初始化(编码器:) being called when I provide an init() function

我正在使用SpriteKit,我正在加载一个SceneKit文件,其中包含许多带有自定义类的Sprite。场景实际上从未加载过,因为它到达第一个自定义类并从requiredinit?(coder:)初始化程序中抛出fatalerror。尽管自定义类实现了一个初始化器,但我无法确定为什么它选择该初始化器而不是我提供的初始化器。自定义类:classBat:SKSpriteNode,GameSprite{varinitialSize:CGSize=CGSize(width:44,height:24)vartextureAtlas:SKTextureAtlas=SKTextureAtlas(n

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

swift 4 : Cannot call value of non-function type '[Self.Element.Type]' when instantiating associated type array

我在这篇文章(https://www.uraimo.com/2016/01/06/10-Swift-One-Liners-To-Impress-Your-Friends/)中对Xcode9beta2Swift4做了一些练习,当时我在执行第1项时遇到错误。6:extensionSequence{typealiasElement=Self.Iterator.ElementfuncpartitionBy(fu:(Element)->Bool)->([Element],[Element]){varfirst=[Element]()varsecond=[Element]()forelinself

ios - 编译器在删除函数数组中的索引时提示 'Expression resolved to unused function'

我用2种类型创建了这个测试用例,正如预期的那样,“Int”用例有效。回调一个没有。不知道为什么会这样。我一直在尝试很多事情。我可能遗漏了一些明显的东西?typealiasType1=InttypealiasType2=([AnyObject?])->VoidclassTest{privatevarcb1:[Type1]privatevarcb2:[Type2]init(){cb1=[Type1](count:2,repeatedValue:0)cb2=[Type2](count:2,repeatedValue:{_in})}funcremoveAtIndex(index:Int){cb

iOS - 在 Swift 中,我们是 "send a message"还是 "call method/function"?

Swift是在编译时保留方法查找列表还是在特定内存位置调用函数?最好的问候。关于此:http://davedelong.tumblr.com/post/58428190187/an-observation-on-objective-c 最佳答案 我建议您查看以下链接,尤其是第一个,因为它通过C++和Objective-C的示例解释了概念,以便更好地理解静态、延迟和动态调度之间的区别(对于方法)。简而言之:静态调度函数及其实现在编译时确定,因此不会在运行时失败(因为除非绑定(bind)成功,否则编译器不会继续编译过程)。延迟发送函数在

ios - swift 和 Realm : Invalid use of '()' to call a value of non-function type 'module<Realm>'

我实际上是从Swift的官方Realm文档中复制和粘贴代码-但它无法编译:https://realm.io/docs/swift/latest/#adding-objects我正在使用Realm1.0.2文档确实自相矛盾-不同的Realm声明:letrealm=RLMRealm.defaultRealm()letrealm=Realm()letrealm=try!Realm()Realm是怎么回事?Realm和RLMRealm有什么区别?上面的第一行可以正常编译-但接下来的两行不会。 最佳答案 Iamliterallycopying