Revision: 22576
http://sourceforge.net/p/bibdesk/svn/22576
Author: hofman
Date: 2018-09-10 16:34:47 +0000 (Mon, 10 Sep 2018)
Log Message:
-----------
check all objects in array
Modified Paths:
--------------
trunk/bibdesk/BDSKAddCommand.m
Modified: trunk/bibdesk/BDSKAddCommand.m
===================================================================
--- trunk/bibdesk/BDSKAddCommand.m 2018-09-10 16:11:21 UTC (rev 22575)
+++ trunk/bibdesk/BDSKAddCommand.m 2018-09-10 16:34:47 UTC (rev 22576)
@@ -46,6 +46,24 @@
@implementation BDSKAddCommand
+static inline BOOL objectsRespondToSelector(NSArray *objects, SEL selector) {
+ if ([objects count] == 0)
+ return NO;
+ for (id obj in objects)
+ if ([obj respondsToSelector:selector] == NO)
+ return NO;
+ return YES;
+}
+
+static inline BOOL objectsAreKindOfClass(NSArray *objects, Class aClass) {
+ if ([objects count] == 0)
+ return NO;
+ for (id obj in objects)
+ if ([obj isKindOfClass:aClass] == NO)
+ return NO;
+ return YES;
+}
+
- (id)performDefaultImplementation {
// get the actual objects to insert
id directParameter = [self directParameter];
@@ -52,7 +70,6 @@
id receiver = [self evaluatedReceivers];
NSArray *insertionObjects = nil;
NSMutableArray *returnValue = nil;
- id obj;
BOOL isArray;
if ([directParameter isKindOfClass:[NSAppleEventDescriptor class]] &&
[directParameter descriptorType] == typeAEList) {
@@ -68,13 +85,12 @@
if (directParameter && [directParameter isKindOfClass:[NSArray class]] ==
NO)
directParameter = [NSArray arrayWithObjects:directParameter, nil];
- obj = [directParameter firstObject];
- if ([obj respondsToSelector:@selector(keyClassDescription)]) {
+ if (NSNotFound == [directParameter indexOfObjectPassingTest:^BOOL(id obj,
NSUInteger idx, BOOL *stop){ return NO == [obj
respondsToSelector:@selector(keyClassDescription)]; }]) {
insertionObjects = [receiver isKindOfClass:[NSArray class]] ? receiver
: [NSArray arrayWithObjects:receiver, nil];
- } else if ([obj isKindOfClass:[NSAppleEventDescriptor class]]) {
- if ([obj fileURLValue])
+ } else if (NSNotFound == [directParameter
indexOfObjectPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop){ return NO
== [obj isKindOfClass:[NSAppleEventDescriptor class]]; }]) {
+ if (NSNotFound == [directParameter indexOfObjectPassingTest:^BOOL(id
obj, NSUInteger idx, BOOL *stop){ return nil == [obj fileURLValue]; }])
insertionObjects = [directParameter valueForKey:@"fileURLValue"];
- else if ((obj = [obj stringValue]) && [NSURL URLWithString:obj])
+ else if (NSNotFound == [directParameter
indexOfObjectPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop){ obj = [obj
stringValue]; return nil == obj || nil == [NSURL URLWithString:obj]; }])
insertionObjects = [directParameter valueForKey:@"stringValue"];
}
@@ -137,16 +153,16 @@
} else {
// insert using scripting KVC
if (insertionIndex >= 0) {
- for (obj in insertionObjects)
+ for (id obj in insertionObjects)
[insertionContainer insertValue:obj
atIndex:insertionIndex++ inPropertyWithKey:insertionKey];
} else {
- for (obj in insertionObjects)
+ for (id obj in insertionObjects)
[insertionContainer insertValue:obj
inPropertyWithKey:insertionKey];
}
// get the return value, either by getting the objectSpecifier
or the AppleEventDescriptor
returnValue = [NSMutableArray array];
- for (obj in insertionObjects) {
+ for (id obj in insertionObjects) {
id returnObj = nil;
if ([obj respondsToSelector:@selector(objectSpecifier)])
returnObj = [obj objectSpecifier];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit