问题描述
我需要帮助。我有一个 SpriteKit 场景并使用更新功能来更改场景的属性。此属性用于 ZStack 中的圆形视图。当我点击按钮时,Xcode 的泄漏工具中检测到内存泄漏。这是一个错误还是为什么会发生这种情况?按钮只是在控制台上打印一些东西。
import SwiftUI
import SpriteKit
class Game: SKScene,ObservableObject{
@Published var lenght: CGFloat = 1
var up: Bool = false
func change(){
if self.lenght > 200 {
up = false
}else if (self.lenght < 5){
up = true
}
up ? (self.lenght += 1) : (self.lenght -= 1)
}
override func update(_ currentTime: TimeInterval) {
self.change()
}
}
struct ContentView: View {
@Observedobject var game = Game()
var body: some View {
ZStack{
SpriteView(scene: game)
Circle().frame(width: game.lenght,height: game.lenght)
.foregroundColor(.white)
Button("hello"){
print("hello")
}
.frame(width: 50,height: 20)
.foregroundColor(.black)
.background(Color.blue)
}
}
}
泄漏是:nsxpcconnection remoteObjectProxyWithErrorHandler
如果我将按钮更改为:
Button("hello"){
print("hello")
game.lenght = 30
}
然后在Malloc 64 Byte条目中QuartzCore之间出现了这个库:
“AxcoreUtilities”
我真的希望有人知道这里发生了什么。感谢您的回答。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)