• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqtwindows誰得cocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

SWFファイル内の画像を表示/書き出しするGUIツール


Commit MetaInfo

Revisionc22673fd7f0c390897eadc4e95def8c184fe5f25 (tree)
Zeit2016-10-02 09:24:27
Autormasakih <masakih@user...>
Commitermasakih

Log Message

HMSwfDocumentをSwiftに書き換えた

Ändern Zusammenfassung

Diff

--- a/KoreNoKaraSu.xcodeproj/project.pbxproj
+++ b/KoreNoKaraSu.xcodeproj/project.pbxproj
@@ -9,16 +9,15 @@
99 /* Begin PBXBuildFile section */
1010 F42ADB271D9A91D300407165 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F42ADB261D9A91D300407165 /* AppDelegate.m */; };
1111 F42ADB2A1D9A91D300407165 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F42ADB291D9A91D300407165 /* main.m */; };
12- F42ADB2D1D9A91D300407165 /* HMSwfDocument.m in Sources */ = {isa = PBXBuildFile; fileRef = F42ADB2C1D9A91D300407165 /* HMSwfDocument.m */; };
1312 F42ADB301D9A91D400407165 /* HMSwfDocument.xib in Resources */ = {isa = PBXBuildFile; fileRef = F42ADB2E1D9A91D400407165 /* HMSwfDocument.xib */; };
1413 F42ADB321D9A91D400407165 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F42ADB311D9A91D400407165 /* Assets.xcassets */; };
1514 F42ADB351D9A91D400407165 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F42ADB331D9A91D400407165 /* MainMenu.xib */; };
1615 F42ADB401D9A942A00407165 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = F42ADB421D9A942A00407165 /* InfoPlist.strings */; };
1716 F42ADB451D9A96ED00407165 /* HMSwfImage.m in Sources */ = {isa = PBXBuildFile; fileRef = F42ADB441D9A96ED00407165 /* HMSwfImage.m */; };
1817 F42ADB4C1D9AA56000407165 /* KanColleGraphicDivider in Resources */ = {isa = PBXBuildFile; fileRef = F42ADB4B1D9AA56000407165 /* KanColleGraphicDivider */; };
19- F42ADB4F1D9AC37600407165 /* NSString-extensions.m in Sources */ = {isa = PBXBuildFile; fileRef = F42ADB4E1D9AC37600407165 /* NSString-extensions.m */; };
2018 F42ADB651D9BFDED00407165 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = F42ADB631D9BFDED00407165 /* Localizable.strings */; };
2119 F42ADB681D9D5F1300407165 /* HMTemporaryDirectory.m in Sources */ = {isa = PBXBuildFile; fileRef = F42ADB671D9D5F1300407165 /* HMTemporaryDirectory.m */; };
20+ F42ADB6C1D9FC7FD00407165 /* HMSwfDocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = F42ADB6B1D9FC7FD00407165 /* HMSwfDocument.swift */; };
2221 /* End PBXBuildFile section */
2322
2423 /* Begin PBXContainerItemProxy section */
@@ -43,8 +42,6 @@
4342 F42ADB251D9A91D300407165 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
4443 F42ADB261D9A91D300407165 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
4544 F42ADB291D9A91D300407165 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
46- F42ADB2B1D9A91D300407165 /* HMSwfDocument.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HMSwfDocument.h; sourceTree = "<group>"; };
47- F42ADB2C1D9A91D300407165 /* HMSwfDocument.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HMSwfDocument.m; sourceTree = "<group>"; };
4845 F42ADB2F1D9A91D400407165 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/HMSwfDocument.xib; sourceTree = "<group>"; };
4946 F42ADB311D9A91D400407165 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
5047 F42ADB341D9A91D400407165 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
@@ -56,13 +53,13 @@
5653 F42ADB441D9A96ED00407165 /* HMSwfImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMSwfImage.m; sourceTree = "<group>"; };
5754 F42ADB471D9AA3EA00407165 /* KanColleGraphicDivider */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; name = KanColleGraphicDivider; path = "../../Library/Developer/Xcode/DerivedData/KoreNoKaraSu-azymafwtbfcomieoipkjtpgiffzd/Build/Products/Debug/KanColleGraphicDivider"; sourceTree = "<group>"; };
5855 F42ADB4B1D9AA56000407165 /* KanColleGraphicDivider */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; path = KanColleGraphicDivider; sourceTree = BUILT_PRODUCTS_DIR; };
59- F42ADB4D1D9AC37600407165 /* NSString-extensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString-extensions.h"; sourceTree = "<group>"; };
60- F42ADB4E1D9AC37600407165 /* NSString-extensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString-extensions.m"; sourceTree = "<group>"; };
6156 F42ADB581D9BFCD100407165 /* KanColleGraphicDivider.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = KanColleGraphicDivider.xcodeproj; path = KanColleGraphicDivider/KanColleGraphicDivider.xcodeproj; sourceTree = "<group>"; };
6257 F42ADB611D9BFD5600407165 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text; name = ja; path = ja.lproj/Localizable.strings.sed; sourceTree = "<group>"; };
6358 F42ADB641D9BFDED00407165 /* ja */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = "<group>"; };
6459 F42ADB661D9D5F1300407165 /* HMTemporaryDirectory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMTemporaryDirectory.h; sourceTree = "<group>"; };
6560 F42ADB671D9D5F1300407165 /* HMTemporaryDirectory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMTemporaryDirectory.m; sourceTree = "<group>"; };
61+ F42ADB6A1D9FC7FC00407165 /* KoreNoKaraSu-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "KoreNoKaraSu-Bridging-Header.h"; sourceTree = "<group>"; };
62+ F42ADB6B1D9FC7FD00407165 /* HMSwfDocument.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMSwfDocument.swift; sourceTree = "<group>"; };
6663 /* End PBXFileReference section */
6764
6865 /* Begin PBXFrameworksBuildPhase section */
@@ -100,15 +97,12 @@
10097 children = (
10198 F42ADB251D9A91D300407165 /* AppDelegate.h */,
10299 F42ADB261D9A91D300407165 /* AppDelegate.m */,
103- F42ADB2B1D9A91D300407165 /* HMSwfDocument.h */,
104- F42ADB2C1D9A91D300407165 /* HMSwfDocument.m */,
100+ F42ADB6B1D9FC7FD00407165 /* HMSwfDocument.swift */,
105101 F42ADB2E1D9A91D400407165 /* HMSwfDocument.xib */,
106102 F42ADB431D9A96ED00407165 /* HMSwfImage.h */,
107103 F42ADB441D9A96ED00407165 /* HMSwfImage.m */,
108104 F42ADB661D9D5F1300407165 /* HMTemporaryDirectory.h */,
109105 F42ADB671D9D5F1300407165 /* HMTemporaryDirectory.m */,
110- F42ADB4D1D9AC37600407165 /* NSString-extensions.h */,
111- F42ADB4E1D9AC37600407165 /* NSString-extensions.m */,
112106 F42ADB311D9A91D400407165 /* Assets.xcassets */,
113107 F42ADB331D9A91D400407165 /* MainMenu.xib */,
114108 F42ADB361D9A91D400407165 /* Info.plist */,
@@ -116,6 +110,7 @@
116110 F42ADB601D9BFD5600407165 /* Localizable.strings.sed */,
117111 F42ADB631D9BFDED00407165 /* Localizable.strings */,
118112 F42ADB281D9A91D300407165 /* Supporting Files */,
113+ F42ADB6A1D9FC7FC00407165 /* KoreNoKaraSu-Bridging-Header.h */,
119114 );
120115 path = KoreNoKaraSu;
121116 sourceTree = "<group>";
@@ -176,6 +171,7 @@
176171 TargetAttributes = {
177172 F42ADB211D9A91D300407165 = {
178173 CreatedOnToolsVersion = 8.0;
174+ LastSwiftMigration = 0800;
179175 ProvisioningStyle = Automatic;
180176 };
181177 };
@@ -236,10 +232,9 @@
236232 isa = PBXSourcesBuildPhase;
237233 buildActionMask = 2147483647;
238234 files = (
239- F42ADB2D1D9A91D300407165 /* HMSwfDocument.m in Sources */,
235+ F42ADB6C1D9FC7FD00407165 /* HMSwfDocument.swift in Sources */,
240236 F42ADB2A1D9A91D300407165 /* main.m in Sources */,
241237 F42ADB681D9D5F1300407165 /* HMTemporaryDirectory.m in Sources */,
242- F42ADB4F1D9AC37600407165 /* NSString-extensions.m in Sources */,
243238 F42ADB271D9A91D300407165 /* AppDelegate.m in Sources */,
244239 F42ADB451D9A96ED00407165 /* HMSwfImage.m in Sources */,
245240 );
@@ -394,11 +389,15 @@
394389 isa = XCBuildConfiguration;
395390 buildSettings = {
396391 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
392+ CLANG_ENABLE_MODULES = YES;
397393 COMBINE_HIDPI_IMAGES = YES;
398394 INFOPLIST_FILE = KoreNoKaraSu/Info.plist;
399395 LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
400396 PRODUCT_BUNDLE_IDENTIFIER = com.masakih.KoreNoKaraSu;
401397 PRODUCT_NAME = "$(TARGET_NAME)";
398+ SWIFT_OBJC_BRIDGING_HEADER = "KoreNoKaraSu/KoreNoKaraSu-Bridging-Header.h";
399+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
400+ SWIFT_VERSION = 3.0;
402401 };
403402 name = Debug;
404403 };
@@ -406,11 +405,14 @@
406405 isa = XCBuildConfiguration;
407406 buildSettings = {
408407 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
408+ CLANG_ENABLE_MODULES = YES;
409409 COMBINE_HIDPI_IMAGES = YES;
410410 INFOPLIST_FILE = KoreNoKaraSu/Info.plist;
411411 LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
412412 PRODUCT_BUNDLE_IDENTIFIER = com.masakih.KoreNoKaraSu;
413413 PRODUCT_NAME = "$(TARGET_NAME)";
414+ SWIFT_OBJC_BRIDGING_HEADER = "KoreNoKaraSu/KoreNoKaraSu-Bridging-Header.h";
415+ SWIFT_VERSION = 3.0;
414416 };
415417 name = Release;
416418 };
--- a/KoreNoKaraSu/Base.lproj/HMSwfDocument.xib
+++ b/KoreNoKaraSu/Base.lproj/HMSwfDocument.xib
@@ -5,7 +5,7 @@
55 <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11201"/>
66 </dependencies>
77 <objects>
8- <customObject id="-2" userLabel="File's Owner" customClass="HMSwfDocument">
8+ <customObject id="-2" userLabel="File's Owner" customClass="HMSwfDocument" customModule="KoreNoKaraSu">
99 <connections>
1010 <outlet property="imagesController" destination="UYM-GR-Pyx" id="blM-N9-Oui"/>
1111 <outlet property="tableView" destination="NMJ-z5-Ntb" id="GRu-aX-QKs"/>
@@ -163,14 +163,14 @@
163163 <menuItem title="Copy" id="d9p-PZ-3gg">
164164 <modifierMask key="keyEquivalentModifierMask"/>
165165 <connections>
166- <action selector="copy:" target="-2" id="ggr-15-tiC"/>
166+ <action selector="copy:" target="-2" id="DrN-sI-Lay"/>
167167 </connections>
168168 </menuItem>
169169 <menuItem isSeparatorItem="YES" id="fON-ES-Oye"/>
170170 <menuItem title="Export…" id="IWB-MT-07s">
171171 <modifierMask key="keyEquivalentModifierMask"/>
172172 <connections>
173- <action selector="exportSelection:" target="-2" id="2AZ-lX-15U"/>
173+ <action selector="exportSelection:" target="-2" id="svI-u6-z6K"/>
174174 </connections>
175175 </menuItem>
176176 </items>
--- a/KoreNoKaraSu/HMSwfDocument.h
+++ /dev/null
@@ -1,16 +0,0 @@
1-//
2-// Document.h
3-// KoreNoKaraSu
4-//
5-// Created by Hori,Masaki on 2016/09/27.
6-// Copyright © 2016年 Hori,Masaki. All rights reserved.
7-//
8-
9-#import <Cocoa/Cocoa.h>
10-
11-@interface HMSwfDocument : NSDocument
12-
13-- (IBAction)exportSelection:(id)sender;
14-
15-@end
16-
--- a/KoreNoKaraSu/HMSwfDocument.m
+++ /dev/null
@@ -1,163 +0,0 @@
1-//
2-// Document.m
3-// KoreNoKaraSu
4-//
5-// Created by Hori,Masaki on 2016/09/27.
6-// Copyright © 2016年 Hori,Masaki. All rights reserved.
7-//
8-
9-#import "HMSwfDocument.h"
10-#import "HMTemporaryDirectory.h"
11-
12-#import "HMSwfImage.h"
13-
14-#import "NSString-extensions.h"
15-
16-
17-@interface HMSwfDocument ()
18-
19-@property (weak, nonatomic) IBOutlet NSTableView *tableView;
20-@property (weak, nonatomic) IBOutlet NSArrayController *imagesController;
21-
22-@property (copy) NSArray<HMSwfImage *> *swfImages;
23-
24-@property (strong) HMTemporaryDirectory *temporaryDirectorhy;
25-
26-@property BOOL didExtract;
27-@end
28-
29-@implementation HMSwfDocument
30-
31-- (NSString *)windowNibName {
32- return @"HMSwfDocument";
33-}
34-
35-- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError {
36-
37- NSBundle *mainBundle = [NSBundle mainBundle];
38- NSString *path = [mainBundle pathForResource:@"KanColleGraphicDivider" ofType:nil];
39- if(!path) {
40- NSBeep();
41- return NO;
42- }
43-
44- self.temporaryDirectorhy = [HMTemporaryDirectory temporaryDirectoryWithName:self.fileURL.path.lastPathComponent.stringByDeletingPathExtension];
45- if(!self.temporaryDirectorhy) {
46- NSLog(@"can not create HMTemporaryDirectory.");
47- NSBeep();
48- return NO;
49- }
50-
51- NSTask *task = [NSTask new];
52- task.launchPath = path;
53- task.arguments = @[
54- @"-o",
55- self.temporaryDirectorhy.fullpath,
56- self.fileURL.path
57- ];
58-
59- task.terminationHandler = ^(NSTask *task) {
60- NSFileManager *fm = [NSFileManager defaultManager];
61- NSArray<NSURL *> *imageURLs = [fm contentsOfDirectoryAtURL:self.temporaryDirectorhy.URL
62- includingPropertiesForKeys:nil
63- options:0
64- error:NULL];
65- NSMutableArray<HMSwfImage *> *images = [NSMutableArray array];
66- for(NSURL *imageURL in imageURLs) {
67- NSImage *image = [[NSImage alloc] initWithContentsOfURL:imageURL];
68- if(!image) {
69- NSLog(@"can not create image from %@", imageURL.path);
70- continue;
71- }
72- HMSwfImage *swfImage = [HMSwfImage new];
73- swfImage.image = image;
74- swfImage.filepath = imageURL.path;
75-
76- [images addObject:swfImage];
77- }
78-
79- NSArray<HMSwfImage *> *swfImages = [images sortedArrayUsingComparator:^NSComparisonResult(HMSwfImage * _Nonnull obj1, HMSwfImage * _Nonnull obj2) {
80- return [obj1.name numericCompare:obj2.name];
81- }];
82-
83- dispatch_async(dispatch_get_main_queue(), ^{
84- self.swfImages = swfImages;
85- self.didExtract = YES;
86- });
87- };
88-
89- [task launch];
90-
91- return YES;
92-}
93-
94-- (HMSwfImage *)actionTarget
95-{
96- HMSwfImage *swfImage = nil;
97-
98- NSInteger row = [self.tableView clickedRow];
99- if(row != -1 || row < self.swfImages.count) {
100- swfImage = self.swfImages[row];
101- }
102-
103- if(!swfImage) {
104- NSIndexSet *selectionIndexes = self.imagesController.selectionIndexes;
105- NSArray *selection = [self.swfImages objectsAtIndexes:selectionIndexes];
106- if(selection.count == 0) return nil;
107- swfImage = selection[0];
108- }
109-
110- return swfImage;
111-}
112-
113-- (IBAction)exportSelection:(id)sender
114-{
115- HMSwfImage *swfImage = [self actionTarget];
116- if(!swfImage) return;
117-
118- NSSavePanel *panel = [NSSavePanel savePanel];
119- panel.allowedFileTypes = @[swfImage.filepath.pathExtension];
120- panel.prompt = [NSString stringWithFormat:NSLocalizedString(@"Export", @"Save Panel - Export")];
121- panel.message = [NSString stringWithFormat:NSLocalizedString(@"Export image of %@", @"Save Panel - Message"), swfImage.name];
122-
123- [panel beginSheetModalForWindow:self.windowForSheet
124- completionHandler:^(NSInteger result) {
125- if(result == NSModalResponseCancel) return;
126-
127- NSFileManager *fm = [NSFileManager defaultManager];
128- NSError *error = nil;
129-
130- if([fm fileExistsAtPath:panel.URL.path]) {
131- if(![fm removeItemAtURL:panel.URL
132- error:&error]) {
133- if(error) {
134- NSLog(@"%@", error);
135- return;
136- }
137- NSLog(@"Fail remove item");
138- return;
139- }
140- }
141-
142- error = nil;
143- if(![fm copyItemAtURL:[NSURL fileURLWithPath:swfImage.filepath]
144- toURL:panel.URL
145- error:&error]) {
146- if(error) {
147- NSLog(@"%@", error);
148- return;
149- }
150- NSLog(@"Fail copy item");
151- }
152- }];
153-}
154-
155-- (IBAction)copy:(id)sender
156-{
157- HMSwfImage *swfImage = [self actionTarget];
158- NSPasteboard *pb = [NSPasteboard generalPasteboard];
159- [pb clearContents];
160- [pb writeObjects:@[swfImage.image]];
161-}
162-
163-@end
--- /dev/null
+++ b/KoreNoKaraSu/HMSwfDocument.swift
@@ -0,0 +1,132 @@
1+//
2+// HMSwfDocument.swift
3+// KoreNoKaraSu
4+//
5+// Created by Hori,Masaki on 2016/10/01.
6+// Copyright © 2016年 Hori,Masaki. All rights reserved.
7+//
8+
9+import Cocoa
10+
11+enum HMSwfDocumentError : Error {
12+ case CanNotOpenResource
13+ case NotFoundBaseName
14+ case CanNotCreateTemporaryDirectory
15+}
16+
17+extension String {
18+ func numericCompare(_ str: String, order: ComparisonResult = .orderedAscending) -> Bool {
19+ return compare(str, options: .numeric, range: nil, locale: nil) == order ? true : false
20+ }
21+}
22+
23+extension Collection {
24+ func objects(atIndexes: IndexSet) -> [Self.Iterator.Element] {
25+ return enumerated().filter { atIndexes.contains($0.0) }.map { $0.1 }
26+ }
27+}
28+
29+class HMSwfDocument: NSDocument {
30+ @IBOutlet var tableView: NSTableView?
31+ @IBOutlet var imagesController: NSArrayController?
32+ dynamic var swfImages: [HMSwfImage]?
33+ dynamic var didExtract = false
34+
35+ private var temporaryDirectory: HMTemporaryDirectory?
36+
37+ override var windowNibName: String? {
38+ get {
39+ return "HMSwfDocument"
40+ }
41+ }
42+
43+ override func read(from url: URL, ofType typeName: String) throws {
44+ guard let path = Bundle.main.path(forResource: "KanColleGraphicDivider", ofType: nil) else {
45+ throw HMSwfDocumentError.CanNotOpenResource
46+ }
47+ guard let basename = fileURL?.deletingPathExtension().lastPathComponent else {
48+ throw HMSwfDocumentError.NotFoundBaseName
49+ }
50+ temporaryDirectory = HMTemporaryDirectory(name: basename)
51+ guard temporaryDirectory != nil else {
52+ Swift.print("can not create HMTemporaryDirectory.")
53+ throw HMSwfDocumentError.CanNotCreateTemporaryDirectory
54+ }
55+
56+ let task = Process()
57+ task.launchPath = path
58+ task.arguments = ["-o",
59+ temporaryDirectory!.fullpath,
60+ fileURL!.path
61+ ]
62+ task.terminationHandler = { (task: Process) in
63+ let fm = FileManager.`default`
64+ guard let imageURLs = try? fm.contentsOfDirectory(at: self.temporaryDirectory!.url,
65+ includingPropertiesForKeys: nil,
66+ options: .skipsSubdirectoryDescendants)
67+ else { return }
68+ let images: [HMSwfImage] = imageURLs.flatMap {
69+ guard let image = NSImage(contentsOf: $0) else {
70+ Swift.print("can not create image from \($0.path)")
71+ return nil
72+ }
73+ let swfImage = HMSwfImage()
74+ swfImage.image = image
75+ swfImage.filepath = $0.path
76+
77+ return swfImage
78+ }.sorted {
79+ $0.name.numericCompare($1.name)
80+ }
81+ DispatchQueue.main.async {
82+ self.swfImages = images
83+ self.didExtract = true
84+ }
85+ }
86+ task.launch()
87+ }
88+
89+ func actionTarget() -> HMSwfImage? {
90+ guard swfImages != nil else { return nil }
91+
92+ let row = tableView!.clickedRow
93+ if row != -1 || row < swfImages!.count {
94+ return swfImages![row]
95+ }
96+
97+ let selectionIndexes = imagesController!.selectionIndexes
98+ let selection = swfImages!.objects(atIndexes: selectionIndexes)
99+ guard selection.count != 0 else { return nil }
100+ return selection[0]
101+ }
102+
103+ @IBAction func exportSelection(_ sender: AnyObject) {
104+ guard let target = actionTarget() else { return }
105+
106+ let panel = NSSavePanel()
107+ panel.allowedFileTypes = [target.url.pathExtension]
108+ panel.prompt = NSLocalizedString("Export", comment: "Save Panel - Export")
109+ panel.message = NSString(format: NSLocalizedString("Export image of %@", comment: "Save Panel - Message") as NSString, target.name) as String!
110+ panel.beginSheetModal(for: windowForSheet!) {
111+ guard $0 != NSModalResponseCancel else { return }
112+
113+ if FileManager().fileExists(atPath: panel.url!.path) {
114+ guard let _ = try? FileManager().removeItem(at: panel.url!) else {
115+ Swift.print("Fail to remove item.")
116+ return
117+ }
118+ }
119+ guard let _ = try? FileManager().copyItem(at: target.url, to: panel.url!) else {
120+ Swift.print("Fail to copy item")
121+ return
122+ }
123+ }
124+ }
125+
126+ @IBAction func copy(_ sender: AnyObject) {
127+ guard let target = actionTarget() else { return }
128+ let pasteboard = NSPasteboard.general()
129+ pasteboard.clearContents()
130+ pasteboard.writeObjects([target.image])
131+ }
132+}
--- a/KoreNoKaraSu/HMSwfImage.h
+++ b/KoreNoKaraSu/HMSwfImage.h
@@ -15,5 +15,5 @@
1515
1616 @property (readonly) NSString *name;
1717 @property (readonly) NSString *typeName;
18-
18+@property (readonly) NSURL *URL;
1919 @end
--- a/KoreNoKaraSu/HMSwfImage.m
+++ b/KoreNoKaraSu/HMSwfImage.m
@@ -19,4 +19,8 @@
1919
2020 return filename;
2121 }
22+- (NSURL *)URL
23+{
24+ return [NSURL fileURLWithPath:self.filepath];
25+}
2226 @end
--- a/KoreNoKaraSu/Info.plist
+++ b/KoreNoKaraSu/Info.plist
@@ -22,7 +22,7 @@
2222 <key>CFBundleTypeRole</key>
2323 <string>Viewer</string>
2424 <key>NSDocumentClass</key>
25- <string>HMSwfDocument</string>
25+ <string>$(PRODUCT_MODULE_NAME).HMSwfDocument</string>
2626 </dict>
2727 </array>
2828 <key>CFBundleExecutable</key>
--- /dev/null
+++ b/KoreNoKaraSu/KoreNoKaraSu-Bridging-Header.h
@@ -0,0 +1,6 @@
1+//
2+// Use this file to import your target's public headers that you would like to expose to Swift.
3+//
4+
5+#import "HMSwfImage.h"
6+#import "HMTemporaryDirectory.h"
--- a/KoreNoKaraSu/NSString-extensions.h
+++ /dev/null
@@ -1,14 +0,0 @@
1-//
2-// NSString-extensions.h
3-// KoreNoKaraSu
4-//
5-// Created by Hori,Masaki on 2016/09/28.
6-// Copyright © 2016年 Hori,Masaki. All rights reserved.
7-//
8-
9-#import <Foundation/Foundation.h>
10-
11-@interface NSString (HMNSStringExtensions)
12-- (NSComparisonResult)numericCompare:(NSString *)string;
13-
14-@end
--- a/KoreNoKaraSu/NSString-extensions.m
+++ /dev/null
@@ -1,16 +0,0 @@
1-//
2-// NSString-extensions.m
3-// KoreNoKaraSu
4-//
5-// Created by Hori,Masaki on 2016/09/28.
6-// Copyright © 2016年 Hori,Masaki. All rights reserved.
7-//
8-
9-#import "NSString-extensions.h"
10-
11-@implementation NSString (HMNSStringExtensions)
12-- (NSComparisonResult)numericCompare:(NSString *)string
13-{
14- return [self compare:string options:NSNumericSearch];
15-}
16-@end