Definition at line 203 of file OODeepCopy.m.
◆ ooDeepCopyWithSharedObjects:
| - (id) ooDeepCopyWithSharedObjects: |
|
(NSMutableSet*) | objects |
|
|
implementation |
Definition at line 205 of file OODeepCopy.m.
205 :(NSMutableSet*)objects
206{
208 id* keys = NULL;
209 id* values = NULL;
210 NSDictionary* result =
nil;
211 BOOL tempObjects = NO;
212
213 count = [
self count];
215 return [[NSDictionary dictionary] retain];
216
217 keys = malloc(
sizeof *keys *
count);
218 values = malloc(
sizeof *values *
count);
219 if (keys == NULL || values == NULL) {
220 free(keys);
221 free(values);
222 [NSException raise:NSMallocException format:@"Failed to allocate space for %zu objects in %s.", count, __PRETTY_FUNCTION__];
223 }
224
225
226 if (objects ==
nil) {
227 objects = [[NSMutableSet alloc] init];
228 tempObjects = YES;
229 }
230
231 @try {
232 i = 0;
234
236 {
237 keys[i] = [key ooDeepCopyWithSharedObjects:objects];
238 values[i] = [[self objectForKey:key] ooDeepCopyWithSharedObjects:objects];
239 i++;
240 }
241
242
243 result = [[NSDictionary alloc] initWithObjects:values forKeys:keys count:count];
244 }
245 @finally {
246
247 for (i = 0; i <
count; i++) {
248 [keys[i] release];
249 [values[i] release];
250 }
251
252 free(keys);
253 free(values);
254 if (tempObjects)
255 [objects release];
256 }
257
258
259 return result;
260}
#define foreachkey(VAR, DICT)
References count, foreachkey, and nil.
The documentation for this category was generated from the following file: