deep mutable copy of a NSMutableDictionary

前端 未结 8 1917
醉话见心
醉话见心 2020-11-30 00:55

I am trying to create a deep-copy of a NSMutableDictionary and assign it to another NSMutableDictionary. The dictionary contains a bunch of arrays, each array containing nam

8条回答
  •  忘掉有多难
    2020-11-30 01:19

    Thought I'd update with an answer if you're using ARC.

    The solution Weva has provided works just fine. Nowadays you could do it like this:

    NSMutableDictionary *mutableCopy = (NSMutableDictionary *)CFBridgingRelease(CFPropertyListCreateDeepCopy(kCFAllocatorDefault, (CFDictionaryRef)originalDict, kCFPropertyListMutableContainers));
    

提交回复
热议问题