This chapter mainly introduces some basic properties and proxies of abstract class Nsurlsessiontask
First, Nsurlsessiontask
1. Nsurlsessiontask is the base class for all request tasks and is an abstract class, so it is not possible to create a specific network request task
2. The unique identifier assigned to each task by the system
@property (readonly
3. Request object that the current task is accessing
readonly, copy) nsurlrequest *currentrequest;
4. Request object for the last access of the current task
readonly, copy) nsurlrequest *originalrequest;
5. Response header information for the current task
readonly, copy) Nsurlresponse *response;
6. The data size (in bytes) that the current task has accepted
@property (readonly) int64_t countofbytesreceived;
7. Total data size to be accepted by the current task
@property (readonly) int64_t countofbytesexpectedtoreceive;
8. Size of data already sent by the current task
@property (readonly) int64_t countofbytessent;
9. Total size of data to be sent by the current task
@property (readonly) int64_t countofbytesexpectedtosend;
10. Set the description information for a task
@property (nullable, copy) NSString *taskdescription;
11. Error message if a task request fails
readonly, copy) Nserror *error;
12. Request status of the current task
@property (readonly) nsurlsessiontaskstate state;
Nsurlsessiontaskstate is an enumeration, as follows
1 typedef ns_enum (Nsinteger, nsurlsessiontaskstate) {2Nsurlsessiontaskstaterunning =0,//The current task is accepting data3nsurlsessiontaskstatesuspended =1,//The current task is paused4Nsurlsessiontaskstatecanceling =2,//the current task is canceled and Nsurlsessiontaskdelegate's task:didcompletewitherror is called: Message5nsurlsessiontaskstatecompleted =3,//The current task is complete6} ns_enum_available (Nsurlsession_available, 7_0);
13. Start task, all tasks are called after creation to start the request
-(void) resume;
14. Pausing a task invokes Nsurlsessiontaskdelegate's Task:didcompletewitherror: Method
-(void) cancel;
15. Pausing a task
-(void) suspend;
Ios--nsurlsessiontask