How to calculate total size of NSDictionary object?

后端 未结 4 1221
离开以前
离开以前 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:58

    Might be useful to convert to NSData if your dictionary contains standard classes (eg. NSString) and not custome ones:

    NSDictionary *yourdictionary = ...;
    NSData * data = [NSPropertyListSerialization dataFromPropertyList:yourdictionary
        format:NSPropertyListBinaryFormat_v1_0 errorDescription:NULL];    
    NSLog(@"size of yourdictionary: %d", [data length]);
    

提交回复
热议问题