Anche people far smarter than I am trovare la sintassi per NSExtensionActivationRule
arcana, ma anche un pazzo come me dovrebbe essere in grado di copiare/incollare esempi, no? Purtroppo non riesco nemmeno a far funzionare Apple's examples. L'app host per la mia estensione di azione si arresta in modo anomalo quando si preme il pulsante del foglio di condivisione (traccia dello stack di seguito).Come si impostano i predicati NSExtensionActivationRule?
Si dovrebbe essere in grado di appena impostato NSExtensionActivationRule
come una stringa, giusto? Funziona bene quando l'ho impostato su TRUEPREDICATE
a scopo di debug. Ma se prendo questo semplice esempio da Apple (leggermente modificato per public.image
) e incollarlo in, ho un incidente:
{extensionItems = ({
attachments = ({
registeredTypeIdentifiers = (
"public.image"
);
});
})}
Ho provato la cosa SUBQUERY
troppo:
SUBQUERY($extensionItem.attachments, $attachment,
ANY $attachment.registeredTypeIdentifiers
UTI-CONFORMS-TO "public.image")[email protected] >= 1
Idealmente mi "Mi piacerebbe evitare tutto questo semplicemente usando NSExtensionActivationSupportsImageWithMaxCount
ma come trovato this person, non sembra essere attivato per jpg.
In ogni caso, che la traccia dello stack come promesso:
2015-02-21 23:28:08.644 MobileSlideShow[56997:2414043] Communications error: <OS_xpc_error: <error: 0x4c985f4> { count = 1, contents =
"XPCErrorDescription" => <string: 0x4c9883c> { length = 22, contents = "Connection interrupted" }
}>
2015-02-21 23:28:08.651 MobileSlideShow[56997:2413473] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSMutableArray removeObjectsAtIndexes:]: index set cannot be nil'
*** First throw call stack:
(
0 CoreFoundation 0x04060686 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x03b35a97 objc_exception_throw + 44
2 CoreFoundation 0x03f84ffe -[NSMutableArray removeObjectsAtIndexes:] + 654
3 UIKit 0x01d71d78 _UIApplicationExtensionDiscoveryGetPostprocessedExtensions + 350
4 UIKit 0x01d718e3 -[_UIActivityApplicationExtensionDiscovery activitiesMatchingInputItems:error:updateBlock:] + 1237
5 UIKit 0x01c342f2 -[UIActivityViewController _availableActivitiesForItems:applicationExtensionActivities:] + 594
6 UIKit 0x01c3409b -[UIActivityViewController _availableActivitiesForItems:] + 48
7 UIKit 0x01c3519a -[UIActivityViewController _availableActivities] + 57
8 UIKit 0x01c39552 -[UIActivityViewController activityGroupViewController:availableActivitiesInCategory:] + 65
9 UIKit 0x0195c47f -[UIActivityGroupViewController collectionView:didSelectItemAtIndexPath:] + 251
10 UIKit 0x01b8d94d -[UICollectionView _selectItemAtIndexPath:animated:scrollPosition:notifyDelegate:] + 591
11 UIKit 0x01baced4 -[UICollectionView _userSelectItemAtIndexPath:] + 191
12 UIKit 0x01bad0c8 -[UICollectionView touchesEnded:withEvent:] + 492
13 libobjc.A.dylib 0x03b4b7cd -[NSObject performSelector:withObject:withObject:] + 84
14 UIKit 0x0164f714 forwardTouchMethod + 270
15 UIKit 0x0164f784 -[UIResponder touchesEnded:withEvent:] + 31
16 libobjc.A.dylib 0x03b4b7cd -[NSObject performSelector:withObject:withObject:] + 84
17 UIKit 0x0164f714 forwardTouchMethod + 270
18 UIKit 0x0164f784 -[UIResponder touchesEnded:withEvent:] + 31
19 UIKit 0x014e714a -[UIWindow _sendTouchesForEvent:] + 874
20 UIKit 0x014e7c24 -[UIWindow sendEvent:] + 790
21 UIKit 0x014a5d81 -[UIApplication sendEvent:] + 242
22 UIKit 0x014b613b _UIApplicationHandleEventFromQueueEvent + 21263
23 UIKit 0x01489599 _UIApplicationHandleEventQueue + 2206
24 CoreFoundation 0x03f820ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
25 CoreFoundation 0x03f77c0d __CFRunLoopDoSources0 + 253
26 CoreFoundation 0x03f77168 __CFRunLoopRun + 952
27 CoreFoundation 0x03f76aeb CFRunLoopRunSpecific + 443
28 CoreFoundation 0x03f7691b CFRunLoopRunInMode + 123
29 GraphicsServices 0x0089e2c9 GSEventRunModal + 192
30 GraphicsServices 0x0089e106 GSEventRun + 104
31 UIKit 0x0148d366 UIApplicationMain + 1526
32 MobileSlideShow 0x00092724 MobileSlideShow + 63268
33 libdyld.dylib 0x049dcac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
"Dovresti essere in grado di impostare' NSExtensionActivationRule' come una stringa, giusto? " No, secondo le menzioni multiple nella documentazione, 'NSExtensionActivationRule' deve essere un dizionario. E l'esempio che stai incollando è per la proprietà 'attachments' di un elemento di estensione dell'app, non per' NSExtensionActivationRule' nel tuo info.plist. –
OK, grazie. Di questo mi sono confuso: "Se devi fare un filtro più complesso o più specifico, come distinguere tra public.url e public.image, puoi creare una dichiarazione di predicato, quindi usa la stringa nuda che rappresenta il predicato come valore della chiave NSExtensionActivationRule, "chiave mancante o incomprensibile". – Duc
Sì, sembra che tu possa essere in grado di usare una stringa di predicato (quelli sono quelli che iniziano con 'SUBQUERY') come valore per' NSExtensionActivationRule'. (Non ho mai avuto bisogno di farlo in quel modo.) Ma la stringa che stai attualmente usando è sicuramente quella sbagliata. –