How to calculate total size of NSDictionary object?

后端 未结 4 731
野的像风
野的像风 2021-02-09 06:09

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:46

    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]);
    

提交回复
热议问题