OK to retain ASIHTTPRequest delegate?

前端 未结 3 1382
广开言路
广开言路 2021-01-28 17:35

Is it OK to retain a delegate of a subclass of ASIHTTPRequest?

I made a subclass of ASIHTTPRequest called JSONRequest. Each instan

3条回答
  •  萌比男神i
    2021-01-28 17:53

    I know that this question is originally about ASIHTTPRequest, but people might stumble upon this thread and it might make them think that using ASIHTTPRequest is still best practice - it is not, infact development has stopped in 2011 AFAIK.

    Using more modern HTTP libraries which use blocks by default (I prefer AFNetworking), all variables referenced in fail/success blocks are either copied or retained until the blocks are released. This will spare you this whole memory management headache - except if you use self in one of the blocks, then you will create a retain cycle until the blocks have been released.

提交回复
热议问题