This repository was archived by the owner on Jan 18, 2023. It is now read-only.
forked from MattNewberry/ObjectiveRecord
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathActiveResult.m
More file actions
86 lines (59 loc) · 1.42 KB
/
ActiveResult.m
File metadata and controls
86 lines (59 loc) · 1.42 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//
// ActiveResult.m
// Shopify_Mobile
//
// Created by Matthew Newberry on 8/2/10.
// Copyright 2010 Shopify. All rights reserved.
//
#import "ActiveResult.h"
@implementation ActiveResult
@synthesize urlPath = _urlPath;
@synthesize source = _source;
@synthesize objects=_objects;
@synthesize error=_error;
@synthesize headers=_headers;
- (id) init{
if(self = [super init]){
self.objects = [NSArray array];
}
return self;
}
- (id) initWithResults:(NSArray *)results{
if(self = [self init]){
_objects = [results retain];
}
return self;
}
- (id) initWithSource:(id) resultSource{
if (self = [self init]){
_source = [resultSource retain];
}
return self;
}
- (id) initWithError:(NSError*) errorRef {
if (self = [self init]) {
_error = [errorRef retain];
}
return self;
}
- (id) object{
return _objects != nil && [_objects count] > 0 ? [_objects objectAtIndex:0] : nil;
}
- (BOOL) hasObjects{
return !![_objects count] > 0;
}
- (int) count{
return [self hasObjects] ? [_objects count] : 0;
}
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState*)state objects:(id*)stackbuf count:(NSUInteger)len {
return [_objects countByEnumeratingWithState:state objects:stackbuf count:len];
}
- (void)dealloc{
[_objects release];
[_error release];
[_headers release];
[_source release];
[_urlPath release];
[super dealloc];
}
@end