LCResult
Objective-C
@interface LCResult<__covariant ValueType> : NSObject
Swift
class LCResult<ValueType> : NSObject where ValueType : AnyObject
A lightweight Objective-C analogue of Swift Result.
Represents the outcome of an operation that can either succeed
with a value of ValueType or fail with an NSError.
Exactly one of value or error is non-nil at any time.
-
The successful value of the operation.
nilif the result represents a failure.Declaration
Objective-C
@property (nonatomic, strong, readonly, nullable) ValueType value;Swift
var value: ValueType? { get } -
The error describing why the operation failed.
nilif the result represents a success.Declaration
Objective-C
@property (nonatomic, strong, readonly, nullable) NSError *error;Swift
var error: (any Error)? { get } -
Indicates whether the result contains a successful value.
Declaration
Objective-C
@property (nonatomic, readonly) BOOL isSuccess;Swift
var isSuccess: Bool { get } -
Indicates whether the result contains an error.
Declaration
Objective-C
@property (nonatomic, readonly) BOOL isFailure;Swift
var isFailure: Bool { get } -
Creates a result representing successful completion.
Declaration
Objective-C
+ (nonnull instancetype)success:(nonnull ValueType)value;Swift
class func success(_ value: ValueType) -> SelfParameters
valueThe value produced by the operation.
Return Value
A result containing
valueand no error. -
Creates a result representing failed completion.
Declaration
Objective-C
+ (nonnull instancetype)failure:(nonnull NSError *)error;Swift
class func failure(_ error: any Error) -> SelfParameters
errorThe error describing the failure.
Return Value
A result containing
errorand no value.