Giter Site home page Giter Site logo

iOS 9 about xextensionitem HOT 2 OPEN

irace avatar irace commented on September 28, 2024
iOS 9

from xextensionitem.

Comments (2)

mbbischoff avatar mbbischoff commented on September 28, 2024

How can we resolve this? It seems as though modifying the extension-facing API to support both types of input is the most future-proof course of action

I haven’t watched the session yet, but I did read your notes on it. This seems like an appropriate, if slightly inelegant way to go. I like a lot better than either of these...

  • Go iOS 9 only and not be useful to anyone who needs to support iOS 8 for a while still (bad option, almost no one will use this)
  • Forget about changing the library in the future to better mesh with how activity items work in a post-iOS 9 world (makes this library very useful in the short term but more annoying to use than it needs to be post-iOS 9)

from xextensionitem.

irace avatar irace commented on September 28, 2024

I actually dreamt about this last night. How sad is that?

I think on the extension side, we’d want our custom class to wrap the extension context rather than an individual item. We would no longer be providing a cleaner API on top of NSExtensionItem on the extension side, but we’d be able to provide a uniform API – an array of NSExtensionItem instances and some metadata – regardless of if the input was structured the old way (one XExtensionItemSource) or the new way (a bunch of raw input items plus one XExtensionItemSource.

The new class would look something like this:

@interface XExtensionItemContext : NSObject

/**
 @see `NSExtensionContext`
 */
@property (nonatomic, readonly) NSArray/*<NSExtensionItem>*/ *inputItems;

/**
 @see `XExtensionItemSource`
 */
@property (nonatomic, readonly) NSArray/*<NSString>*/ *tags;

/**
 @see `XExtensionItemSource`
 */
@property (nonatomic, readonly) XExtensionItemReferrer *referrer;

/**
 @see `XExtensionItemSource`
 */
@property (nonatomic, readonly) NSDictionary *userInfo;

/**
 Inialize a new instance with an incoming `NSExtensionContext`.

 @param extensionItemContext Extension context.

 @return New instance populated with the extension context.
 */
- (instancetype)initWithExtensionContext:(NSExtensionContext *)extensionContext NS_DESIGNATED_INITIALIZER;

@end

Title and attributed content text would no longer be something that XExtensionItem concerns itself with, since it would now be augmenting one or more NSExtensionItem instances, rather than expecting to be used in place of them. In short, I think this makes the API slightly less nice in the short term but much more future-proof.

I have an in-progress branch that makes these changes that I’ll happily link to from this issue once I’ve got it a little further along. In the meantime, feedback welcome!

from xextensionitem.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.