forked from alejandrojapkin/CocoaLUT
/
LUTRecipe.m
42 lines (34 loc) · 1.1 KB
/
LUTRecipe.m
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
//
// LUTRecipe.m
// Pods
//
// Created by Wil Gieseler on 7/13/14.
//
//
#import "LUTRecipe.h"
#import "LUTAction.h"
@interface LUTRecipe ()
@property NSMutableArray *actions;
@end
@implementation LUTRecipe
+ (instancetype)recipeWithActions:(NSDictionary *)actions {
LUTRecipe *recipe = [[LUTRecipe alloc] init];
recipe.actions = [actions mutableCopy];
return recipe;
}
- (NSArray *)serializableArray {
NSMutableArray *formattedArray = [NSMutableArray array];
for (LUTAction *action in self.actions) {
[formattedArray addObject:NSDictionaryFromM13OrderedDictionary(action.actionMetadata)];
}
return formattedArray;
}
- (NSData *)serializedRecipeWithError:(NSError **)error {
return [NSJSONSerialization dataWithJSONObject:self.serializableArray
options:NSJSONWritingPrettyPrinted
error:error];
}
- (NSString *)serializedRecipeStringWithError:(NSError **)error {
return [[NSString alloc] initWithData:[self serializedRecipeWithError:error] encoding:NSUTF8StringEncoding];
}
@end