-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCoreRequest.m
51 lines (41 loc) · 1.38 KB
/
CoreRequest.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
//
// CoreRequest.m
// CoreResource
//
// Created by Mike Laurence on 12/31/09.
// Copyright 2009 Mike Laurence. All rights reserved.
//
#import "CoreRequest.h"
#import "CoreManager.h"
@implementation CoreRequest
@synthesize coreDelegate, coreSelector;
@synthesize bundleDataPath, bundleDataResult;
- (void) executeAsBundleRequest {
NSError* parseError = nil;
self.bundleDataResult = [NSString stringWithContentsOfFile:
[[NSBundle mainBundle] pathForResource:bundleDataPath ofType:@"json"]
encoding:NSUTF8StringEncoding error:&parseError];
if (parseError == nil) {
if (didFinishSelector && ![self isCancelled] && [delegate respondsToSelector:didFinishSelector]) {
if ([CoreManager main].bundleRequestDelay == 0)
[delegate performSelector:didFinishSelector withObject:self];
else {
[delegate performSelector:didFinishSelector withObject:self afterDelay:[CoreManager main].bundleRequestDelay];
}
}
}
else
[self failWithError:parseError];
}
- (NSString*) stringData {
return bundleDataResult != nil ? bundleDataResult : [self responseString];
}
- (NSString*) responseString {
return bundleDataResult != nil ? bundleDataResult : [super responseString];
}
- (void) dealloc {
[bundleDataResult release];
[bundleDataPath release];
[super dealloc];
}
@end