forked from HunterHillegas/iOS-BetaBuilder
-
Notifications
You must be signed in to change notification settings - Fork 3
/
DragContentView.m
53 lines (41 loc) · 1.54 KB
/
DragContentView.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
52
53
//
// DragContentView.m
// BetaBuilder
//
// Created by Paulo Cesar Saito on 10/17/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "DragContentView.h"
#import "BuilderController.h"
@implementation DragContentView
@synthesize builderController;
- (void) awakeFromNib {
[super awakeFromNib];
NSArray *draggedTypeArray = [NSArray arrayWithObjects:NSFilenamesPboardType, nil];
[self registerForDraggedTypes:draggedTypeArray];
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
NSString *filename = [[[sender draggingPasteboard] propertyListForType:NSFilenamesPboardType] objectAtIndex:0];
if (([[filename lowercaseString] rangeOfString:@".app"].location == NSNotFound ||
[[filename lowercaseString] rangeOfString:@".app.dsym"].location != NSNotFound) &&
[[filename lowercaseString] rangeOfString:@".ipa"].location == NSNotFound) {
return NSDragOperationNone;
}
return NSDragOperationEvery;
}
- (BOOL) prepareForDragOperation:(id <NSDraggingInfo>)sender {
return YES;
}
- (BOOL)performDragOperation:(id < NSDraggingInfo >)sender {
NSArray *draggedFilenames = [[sender draggingPasteboard] propertyListForType:NSFilenamesPboardType];
NSString *filename = [draggedFilenames objectAtIndex:0];
if ([[filename lowercaseString] rangeOfString:@".ipa"].location != NSNotFound)
[self.builderController setupFromIPAFile:filename];
else if ([[filename lowercaseString] rangeOfString:@".app"].location != NSNotFound)
[self.builderController setupFromAPPFile:filename];
else
return NO;
return YES;
}
@end