How to calculate total size of NSDictionary object?

后端 未结 4 1208
离开以前
离开以前 2021-02-09 06:14

How to calculate total size of NSDictionary object? i have 3000 StudentClass objects in NSDictionary with different keys. And i want to calculate total

4条回答
  •  野性不改
    2021-02-09 06:34

    You could try to get all the keys of the Dictionary in an array and then iterate the array to find the size, it might give you the total size of the keys inside the dictionary.

    NSArray *keysArray = [yourDictionary allValues];
    id obj = nil;
    int totalSize = 0;
    
    for(obj in keysArray)
    {
        totalSize += malloc_size(obj);
    }
    

提交回复
热议问题