-
Notifications
You must be signed in to change notification settings - Fork 1
/
LBCreateObjectService.m
39 lines (31 loc) · 1.15 KB
/
LBCreateObjectService.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
//
// CreateObjectService.m
// CheckInToWin
//
// Created by Jacob Morris on 1/4/12.
// Copyright (c) 2012 Bluemodus. All rights reserved.
//
#import <RestKit/RKErrorMessage.h>
#import "LBCreateObjectService.h"
@implementation LBCreateObjectService
@synthesize delegate;
@synthesize target;
+(LBCreateObjectService *)serviceWithDelegate:(NSObject<LBObjectCreationDelegate> *)delegate{
LBCreateObjectService *newService = [[LBCreateObjectService alloc]init];
newService.delegate = delegate;
return newService;
}
-(void)createObject:(NSObject *)theObject withMapping:(RKObjectMapping *)mapping{
self.target = theObject;
[[LBDataManager sharedManager].rkObjectManager
postObject:theObject mapResponseWith:mapping delegate:self];
}
-(void)objectLoader:(RKObjectLoader *)objectLoader didFailWithError:(NSError *)error{
[self.delegate objectDidFailCreation:error];
[super objectLoader:objectLoader didFailWithError:error];
}
-(void)objectLoader:(RKObjectLoader *)objectLoader didLoadObjects:(NSArray *)loadedObjects{
[self.delegate didCreateObject:[loadedObjects objectAtIndex:0]];
[super objectLoader:objectLoader didLoadObjects:loadedObjects];
}
@end