-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathAutoCorrectItem.m
58 lines (48 loc) · 1.54 KB
/
AutoCorrectItem.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
51
52
53
54
55
56
57
58
//
// AutoCorrectItem.m
// AvroKeyboard
//
// Created by Rifat Nabi on 12/8/13.
//
//
#import "AutoCorrectItem.h"
@implementation AutoCorrectItem
@synthesize replace, with;
static NSString * const iAVRO_ERROR_DOMAIN = @"iAvroErrorDomain";
static NSInteger const iAVRO_INVALID_REPLACE_CODE = -1;
static NSInteger const iAVRO_INVALID_WITH_CODE = -2;
- (id)init
{
self = [super init];
if (self) {
replace = @"replace";
with = @"with";
}
return self;
}
-(BOOL)validateReplace:(id *)ioValue error:(NSError * __autoreleasing *)outError {
NSLog(@"Validating...");
return YES;
}
-(BOOL)validateWith:(id *)ioValue error:(NSError * __autoreleasing *)outError {
// The with must not be nil, and must be at least one characters long.
if ((*ioValue == nil) || ([(NSString *)*ioValue length] < 1)) {
if (outError != NULL) {
NSString *errorString = NSLocalizedString(
@"Value of 'With' can't be empty",
@"validation: Value of 'With' can't be empty");
NSDictionary *userInfoDict = @{ NSLocalizedDescriptionKey : errorString };
*outError = [[NSError alloc] initWithDomain:iAVRO_ERROR_DOMAIN
code:iAVRO_INVALID_WITH_CODE
userInfo:userInfoDict];
}
return NO;
}
return YES;
}
-(void)dealloc {
[replace release];
[with release];
[super dealloc];
}
@end