OSDN Git Service

HMServerDataStoreクラスをSwiftで書き換え
[kcd/KCD.git] / KCD / HMRealDestroyShipCommand.m
1 //
2 //  HMRealDestroyShipCommand.m
3 //  KCD
4 //
5 //  Created by Hori,Masaki on 2014/07/20.
6 //  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
7 //
8
9 #import "HMRealDestroyShipCommand.h"
10
11 #import "KCD-Swift.h"
12
13 @implementation HMRealDestroyShipCommand
14 - (void)execute
15 {
16         HMServerDataStore *store = [HMServerDataStore oneTimeEditor];
17         NSManagedObjectContext *moc = store.managedObjectContext;
18         
19         NSString *destroyedShipId = [self.arguments objectForKey:@"api_ship_id"];
20         
21         NSError *error = nil;
22         NSArray *ships = [store objectsWithEntityName:@"Ship"
23                                                                                         error:&error
24                                                                   predicateFormat:@"id = %@", @([destroyedShipId integerValue])];
25         if(ships.count == 0) {
26                 return;
27         }
28         [moc deleteObject:ships[0]];
29 }
30 @end