UserActions
public enum UserActions
A namespace for various UserActions types.
-
A location in the UI where view controllers can be presented from.
On iPhones, action sources aren’t used, but on iPad or Mac, they’re used when an action presents a popover view controller. The source indicates where the popover is shown from.
See moreDeclaration
Swift
public enum Source
-
A context that tracks the lifecycle of a single invocation of a user action.
The context tracks the result of the action and reports it back to the runner. It also provides a way for action implementations to interact with the rest of your app.
See moreDeclaration
Swift
public class Context<Action> where Action : UserAction
-
A key used to store and retrieve app-specific data from a
Context
in a type-safe way.Create one and save it in a constant, specifying the type of value you will store with the key:
let managedObjectContextKey = UserActions.ContextKey<NSManagedObjectContext>()
Then, in the user action runner delegate or in your action types, you can set or get values with that key:
context[managedObjectContextKey] = yourManagedObjectContext // ... let objects = context[managedObjectContextKey]!.fetch(fetchRequest)
You may find it more convenient to define accessors for the key on an extension of
Context
:
See moreprivate let managedObjectContextKey = UserActions.ContextKey<NSManagedObjectContext>() extension UserActions.Context { var managedObjectContext: NSManagedObjectContext { get { self[managedObjectContextKey]! } set { self[managedObjectContextKey] = newValue } } }
Declaration
Swift
public final class ContextKey<T> : Hashable
-
A runner that performs user actions in a particular context of the app.
A
See moreUserAction
does not get performed directly. It describes how to perform an action, but it does not actually do so until an action runner performs it.Declaration
Swift
public class Runner