forked from slip/CourseBuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCBAnswer.m
50 lines (41 loc) · 1.07 KB
/
CBAnswer.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
43
44
45
46
47
48
49
50
//
// CBAnswer.m
// CourseBuilder
//
// Created by Ian Kennedy on 4/1/10.
// Copyright 2010 normal software. All rights reserved.
//
#import "CBAnswer.h"
#import "CBQuestion.h"
#import "Order.h"
@implementation CBAnswer
@dynamic isCorrect;
@dynamic answer;
@dynamic order;
@dynamic question;
- (void)dealloc
{
[super dealloc];
}
- (NSMutableDictionary *)encode
{
// first get all of the values from the object
NSMutableDictionary *dict = [[self dictionaryWithValuesForKeys:[[self entity] attributeKeys]] mutableCopy];
NSDictionary *attributes = [[self entity] attributesByName];
for(NSString *key in attributes)
{
NSAttributeDescription *attribute = [attributes objectForKey:key];
id value = [dict objectForKey:key];
if( (value == nil) || ([value isKindOfClass:[NSNull class]]) )
{
if([attribute attributeType] == NSStringAttributeType)
[dict setObject:@"" forKey:key];
else
[dict removeObjectForKey:key];
}
}
NSNumber *orderNum = [[self order] order];
[dict setValue:orderNum forKey:@"order"];
return [dict autorelease];
}
@end