小编Pin*_*uch的帖子

Watch kit App:由于内存错误而终止

嗨,我正在开发一个应用程序,其中我需要chache 50张图像(所有图像的大小是2.5 MB),它正在追逐图像,但也因Apple应用程序崩溃而在Apple Watch App中增加了10 MB的内存.

Xcode在xCode中给出错误"来自调试器的消息:由于内存错误而终止"

我使用的代码如下:

 for (var i : Int  = 1; i<26; i++) {

            let filenameHuman = NSString(format: "human_%d", i )
            let filenameZombie = NSString(format: "zombie_%d", i )

            var imageHuman : UIImage! =  UIImage(named: filenameHuman as String)
            var imageZombie : UIImage! =  UIImage(named: filenameZombie as String)

            WKInterfaceDevice.currentDevice().addCachedImage(imageZombie, name: filenameZombie as String)

            WKInterfaceDevice.currentDevice().addCachedImage(imageHuman, name: filenameHuman as String)

        }

        NSLog("Currently cached images: %@",WKInterfaceDevice.currentDevice().cachedImages)
Run Code Online (Sandbox Code Playgroud)

内存分配和内存泄漏的屏幕截图是:

在此输入图像描述

请帮助,提前致谢.

ios swift watchkit

5
推荐指数
1
解决办法
1007
查看次数

标签 统计

ios ×1

swift ×1

watchkit ×1