NSExtensionActivationRule for exact one image or video - iOS App extension -
i building app action extension. that, extension should enable if user selects either 1 video or 1 image(it can process 1 file/object @ once). got nsextensionactivationrule
predicate apple documentation this,
subquery ( extensionitems, $extensionitem, subquery ( $extensionitem.attachments, $attachment, $attachment.registeredtypeidentifiers uti-conforms-to "org.appextension.action-one" || $attachment.registeredtypeidentifiers uti-conforms-to "org.appextension.action-two" ).@count == $extensionitem.attachments.@count ).@count == 1
and documentation says
this statement iterates on array of nsextensionitem objects, , secondarily on attachments array in each extension item. each attachment, predicate evaluates uniform type identifier (uti) each representation in attachment. when attachment representation uti conforms of of 2 different specified utis (which see on right-hand side of each uti-conforms-to operator), collect uti final comparison test. final line returns true if app extension given 1 extension item attachment supported uti.
i changed org.appextension.action-two
, org.appextension.action-one
public.image
, public.movie
.
but still extension enabled if select multiple video or images. wrong predicate.
the condition @count == $extensionitem.attachments.@count
means return true if attachments images , videos , doesn't matter how many there, limit 1 change @count == 1
Comments
Post a Comment