GCKRequest.h
1 // Copyright 2015 Google Inc.
2 
3 #import <GoogleCast/GCKDefines.h>
4 
5 #import <Foundation/Foundation.h>
6 
7 @class GCKError;
8 @protocol GCKRequestDelegate;
9 
10 typedef NSInteger GCKRequestID;
11 
12 GCK_ASSUME_NONNULL_BEGIN
13 
20 typedef NS_ENUM(NSInteger, GCKRequestAbortReason) {
22  GCKRequestAbortReasonReplaced = 1,
24  GCKRequestAbortReasonCancelled = 2,
25 };
26 
34 GCK_EXPORT
35 @interface GCKRequest : NSObject
36 
40 @property(nonatomic, weak, readwrite, GCK_NULLABLE) id<GCKRequestDelegate> delegate;
41 
45 @property(nonatomic, assign, readonly) GCKRequestID requestID;
46 
50 @property(nonatomic, copy, readonly, GCK_NULLABLE) GCKError *error;
51 
55 @property(nonatomic, assign, readonly) BOOL inProgress;
56 
63 @property(nonatomic, assign, readonly) BOOL external;
64 
69 - (void)cancel;
70 
79 
88 - (void)complete;
89 
100 - (void)failWithError:(GCKError *)error;
101 
112 - (void)abortWithReason:(GCKRequestAbortReason)reason;
113 
114 @end
115 
121 GCK_EXPORT
122 @protocol GCKRequestDelegate <NSObject>
123 
124 @optional
125 
131 - (void)requestDidComplete:(GCKRequest *)request;
132 
139 - (void)request:(GCKRequest *)request didFailWithError:(GCKError *)error;
140 
148 - (void)request:(GCKRequest *)request didAbortWithReason:(GCKRequestAbortReason)abortReason;
149 
150 @end
151 
152 GCK_ASSUME_NONNULL_END
A subclass of NSError for framework errors.
Definition: GCKError.h:366
An object for tracking an asynchronous request.
Definition: GCKRequest.h:35
BOOL external
A flag indicating whether this is an external request–that is, one created by the application rather...
Definition: GCKRequest.h:63
id< GCKRequestDelegate > delegate
The delegate for receiving notifications about the status of the request.
Definition: GCKRequest.h:40
void cancel()
Cancels the request.
GCKRequestID requestID
The unique ID assigned to this request.
Definition: GCKRequest.h:45
GCKError * error
The error that caused the request to fail, if any, otherwise nil.
Definition: GCKRequest.h:50
BOOL inProgress
A flag indicating whether the request is currently in progress.
Definition: GCKRequest.h:55
GCKRequest * applicationRequest()
Constructs a GCKRequest object for use by the calling application.
void complete()
Completes the request and notifies the delegate accordingly.