¡@

Home 

2014/10/15 ¤U¤È 10:05:10

iphone Programming Glossary: cobjects

how to do true deep copy for NSArray and NSDictionary with have nested arrays/dictionary?

http://stackoverflow.com/questions/5453481/how-to-do-true-deep-copy-for-nsarray-and-nsdictionary-with-have-nested-arrays-di

release return ret @end @implementation NSDictionary SPDeepCopy NSDictionary deepCopy unsigned int count self count id cObjects count id cKeys count NSEnumerator e self keyEnumerator unsigned int i 0 id thisKey while thisKey e nextObject nil id obj.. thisKey while thisKey e nextObject nil id obj self objectForKey thisKey if obj respondsToSelector @selector deepCopy cObjects i obj deepCopy else cObjects i obj copy if thisKey respondsToSelector @selector deepCopy cKeys i thisKey deepCopy else.. nil id obj self objectForKey thisKey if obj respondsToSelector @selector deepCopy cObjects i obj deepCopy else cObjects i obj copy if thisKey respondsToSelector @selector deepCopy cKeys i thisKey deepCopy else cKeys i thisKey copy i NSDictionary..