-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathUUObjectFactory.m
More file actions
51 lines (43 loc) · 1.44 KB
/
UUObjectFactory.m
File metadata and controls
51 lines (43 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// UUObjectFactory.m
// Useful Utilities - Object parsing protocols and helpers
//
// License:
// You are free to use this code for whatever purposes you desire. The only requirement is that you smile everytime you use it.
//
// Contact: @cheesemaker or jon@threejacks.com
//
//
#import "UUObjectFactory.h"
#import "UUHttpResponseHandler.h"
@implementation UUObjectFactory
+ (id) process:(Class)objectFactoryClass object:(id)object context:(id)context
{
id processedResponse = object;
if (objectFactoryClass && [objectFactoryClass conformsToProtocol:@protocol(UUObjectFactory)])
{
if ([object isKindOfClass:[NSDictionary class]])
{
id singleResponse = [objectFactoryClass uuObjectFromDictionary:object withContext:context];
processedResponse = singleResponse;
}
else if ([object isKindOfClass:[NSArray class]])
{
NSMutableArray* list = [NSMutableArray array];
for (id node in object)
{
if ([node isKindOfClass:[NSDictionary class]])
{
id nodeObj = [objectFactoryClass uuObjectFromDictionary:node withContext:context];
if (nodeObj)
{
[list addObject:nodeObj];
}
}
}
processedResponse = list;
}
}
return processedResponse;
}
@end