CBLCameraInitiatedTransferResult

Objective-C

@protocol CBLCameraInitiatedTransferResult <NSObject>

Swift

protocol CameraInitiatedTransferResult : NSObjectProtocol

The result of a camera-initiated transfer.

Result objects are stored entirely locally, and as such are not under the time pressure that the intial camera- initiated transfer object is. However, they can be fairly resource heavy (especially when the transfer is of a RAW image) so it’s recommended that they are dealt with reasonably quickly.

How this object manages its resources is an implementation detail, and any buffers of cache files it creates will be cleaned up when the object is deallocated. To take ownership of the transfer result, use the appropriate methods to extract representations into RAM or to disk.

  • The representations available in this transfer result.

    Declaration

    Objective-C

    @property (nonatomic, readonly) CBLCameraInitiatedTransferRepresentation availableRepresentations;

    Swift

    var availableRepresentations: CameraInitiatedTransferRepresentation { get }
  • Returns YES if the receiver can provide the given representation, otherwise NO.

    Declaration

    Objective-C

    - (BOOL)containsRepresentation:
        (CBLCameraInitiatedTransferRepresentation)representation;

    Swift

    func contains(_ representation: CameraInitiatedTransferRepresentation) -> Bool
  • Returns YES if not saving the contents of this result may cause data loss. For example, a camera set to only save images to the connected host would set this to YES.

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL isOnlyDestinationForImage;

    Swift

    var isOnlyDestinationForImage: Bool { get }
  • A file name hint for the original representation of the image, if available.

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly, nullable) NSString *fileNameHint;

    Swift

    var fileNameHint: String? { get }
  • Returns a suggested file name extension for the given representation or nil if the representation isn’t available.

    To match camera conventions, extensions will be uppercase (“JPG”, “CR3”, “ARW”, “HEIC”, etc).

    Warning

    You must only pass a single representation to this method, otherwise nil will be returned.

    Note

    This method is guaranteed to return a valid value as long as the representation is available. This can be useful if the fileNameHint property is nil and you need to write a representation to disk.

    Declaration

    Objective-C

    - (NSString *_Nullable)suggestedFileNameExtensionForRepresentation:
        (CBLCameraInitiatedTransferRepresentation)representation;

    Swift

    func suggestedFileNameExtension(for representation: CameraInitiatedTransferRepresentation) -> String?
  • Returns the type UTI for the given representation, or nil if the representation isn’t available.

    Warning

    You must only pass a single representation to this method, otherwise nil will be returned.

    Note

    This method may fall back to returning kUTTypeData if the representation is in a RAW image format not recognised by the operating system.

    Declaration

    Objective-C

    - (NSString *_Nullable)utiForRepresentation:
        (CBLCameraInitiatedTransferRepresentation)representation;

    Swift

    func uti(for representation: CameraInitiatedTransferRepresentation) -> String?
  • Write the given representation to disk.

    Warning

    You must only pass a single representation to this method, otherwise an error will be returned.

    Declaration

    Objective-C

    - (void)writeRepresentation:
                (CBLCameraInitiatedTransferRepresentation)representation
                          toURL:(NSURL *_Nonnull)destinationUrl
              completionHandler:
                  (nonnull CBLErrorableOperationCallback)completionHandler;

    Swift

    func write(_ representation: CameraInitiatedTransferRepresentation, to destinationUrl: URL) async throws

    Parameters

    representation

    The representation to write.

    destinationUrl

    The URL at which to write the representation. CascableCore will attempt to create the parent directory tree if it isn’t already present.

    completionHandler

    The completion handler, called on the main queue, when the operation succeeds or fails.

  • Retrieve the given representation as an in-memory data object.

    Warning

    You must only pass a single representation to this method, otherwise an error will be returned.

    Warning

    This operation may fail if the representation is large enough to risk crashes due to high memory usage. If this happens, the resulting error will have the code CBLErrorCodeObjectTooLarge.

    Declaration

    Objective-C

    - (void)generateDataForRepresentation:
                (CBLCameraInitiatedTransferRepresentation)representation
                        completionHandler:
                            (void (^_Nonnull)(NSData *_Nullable,
                                              NSError *_Nullable))completionHandler;

    Swift

    func generateData(for representation: CameraInitiatedTransferRepresentation) async throws -> Data

    Parameters

    representation

    The representation to retrieve.

    completionHandler

    The completion handler, called on the main queue, when the operation succeeds or fails.

  • Generate an image from the preview representation.

    Note

    This method requires that the result contains the CBLCameraInitiatedTransferRepresentationPreview representation.

    Declaration

    Objective-C

    - (void)generatePreviewImage:
        (void (^_Nonnull)(UIImage *_Nullable, NSError *_Nullable))completionHandler;

    Swift

    func generatePreviewImage() async throws -> UIImage

    Parameters

    completionHandler

    The completion handler, called on the main queue, when the operation succeeds or fails.