- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在主包中使用属性列表来存储有关关卡和玩家的信息。第一次启动应用程序时,pList 会被复制到手机上,然后我根据需要从该本地副本访问信息。我在 Instruments 中运行 Leaks,我不断遇到内存泄漏,我认为这些内存泄漏与创建存储在 pList 中的字典和其他数据类型有关。
这是创建字典的地方 - 在找到 pList 的路径之后:
if fileManager.fileExists(atPath: path.path) {
if let dictionaryForPlist = NSMutableDictionary(contentsOf: path) {
return(dictionaryForPlist)
}
else {
print("pList not found")
}
let levelInstanceData = LevelData() //this class searches the main bundle for the plist and stores the pList as an NSMutableDictionary
let currentLevel = levelInstanceData.localDataFile["Level1"] as! Int //localDataFile is the NSMutableDictionary storing the information
let levelName = levelInstanceData.localDataFile["Level1Name"] as! String
我强制将每条数据转换为正确的数据类型,并在整个关卡中使用它。
这是 Instruments 中泄漏对象的屏幕截图。有没有其他人遇到过这个问题或有任何想法如何阻止泄漏?
最佳答案
提供所有泄漏的对象并不过分帮助。您需要做的是查看与每个泄漏对象相关的调用树。这将向您显示泄漏源自代码中的何处。从那里您可以开始推断需要做什么来补救它。
你应该读这个。它已过时,但讨论了调用树。
https://www.raywenderlich.com/2696/instruments-tutorial-for-ios-how-to-debug-memory-leaks
关于ios - 使用 Property List/NSMutableDictionary 的内存泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39969749/
设置 我有一个 NSMutableDictionary,其中包含超过 800 个代表员工的 NSMutableDictionaries。我正在尝试实现一个搜索栏,但在使用我的词典时遇到严重问题。 在第
我有一个 NSMutableDictionary,其中的每个元素都是另一个字典。将其内容复制到另一个 NSMutableDictionary 的最佳方式是什么?我试过使用: firstDictiona
我有 2 个 NSMutableDictionaries,每个都有 5 个 NSArray, 这 2 个 NSMutableDictionaries 有完全相同的 5 个键和 NSArray,但内容不
将 NSMutableDictionary 添加到 NSMutableDictionary 是创建副本还是保留指针。 我希望能够更新第一个 NSMutableDictionary 的内容并在另一个 N
所以我有三个像这样的 NSMutableDictionary: .h文件 NSMutableDictionary *myContainer; NSMutableDictionary *myD1; NS
我想将 NSMUtableDictionary 值复制到另一个 NSMutableDictionary 中。我怎样才能做到这一点? 这是我的代码, PersonClass.h file: NSMu
仍在此处学习 Objective-C/iPhone SDK。我想我知道为什么这不起作用,但我只是想确认一下。 在awakeFromNib中,如果我使用[[NSMutableDictionary all
我在这个数组中有一个 NSArray 和 NSMutableDictionary 对象,如下所示。我想在这个数组的索引:2 处得到一个对象,并将来自以下数组的 NSMutableDictionary
要创建一个空字典,我应该调用 [NSMutableDictionary dictionary] 还是 [[NSMutableDictionary alloc] init]? 有什么区别? 最佳答案 [
对于存储在 NSMutableDictionary 中的字母表中的每个字母,我有 5 个 UIImageView。 5 而不是 1,以防万一他们想要拼写的单词需要更多相同的字母。 我正在创建这样的字母
一旦 NSMutableDictionary 已经达到对象的容量限制,当您尝试添加到它时会发生什么?这会撞出一个还是会抛出异常?当我添加一个新的字典对象时,有没有办法让它撞出最旧的字典对象? 最佳答案
我有 NSMutableDictionary *mutDic; 它加载了来自其他NSMutableDictionary的一些值从警报中我试图更新其值 - (void)alertView:(UIAler
在我的 iPhone 应用程序中,我使用整数来跟踪大量变量。我在我的 AppDelegate 文件(它是一个多 View 应用程序)中声明并初始化了它们,然后如果我在其他 View (类)中声明它们,
我有一个递归函数,可以将以前的字典添加到新字典中,但使用 addEntriesFromDictionary 会出现错误 这是我的示例代码(已编辑) func fetchAllSWApiList
我有一个应用程序可以从 Web 服务下载信息并将其缓存在内存中。具体来说,我的单例缓存类包含一个实例变量 NSMutableDictionary *memoryDirectory,它包含所有缓存数据。
我今天遇到了一个策略错误。我有一个 NSArray 和一个 NSMutableDictionary。问题是我的 NSMutableDictionary 变成了一个数组。这是代码: 标题: NSArra
我的 iOS 应用程序中有以下方法。声明: GMSMarker *marker = [places objectForKey:place]; 并不总能找到关键的对象,当我明确知道有一个对象要找到时。
我有两个 NSMutableDictionay,我们将预期的一个称为“A”,将操作结果的一个称为“B” 我想将“A”和“B”之间的差异插入“C”NSMutableDictionary。 我使用 if
我有一个日期选择器和一个 UIBarButtonItem,当按下 UIBarButtonItem 时,它会调用一个方法将所选日期添加到 NSMutableDictionary。代码如下所示: diar
我在 NSMutableDictionary 中面临非常奇怪的问题。请看下面的代码。 NSMutableDictionary *dict=[[NSMutableDictionary alloc]in
我是一名优秀的程序员,十分优秀!