ios - Block is preventing dealloc although the block was copied -
i believe following rules still problem exists
my class init includes block this:
httpchunkreceiveblock chunkblock = ^(id connection, nsdata *data) { nslog(@"hi there!!"); };
and passing block httpconn obj class holds:
operation_ = [[httpclient sharedclient] performchunkedrequest:url chunkhandler:chunkblock];
now problem: object never deallocated!!
the problem seems caused because httpconn keeping pointer block, want mention 2 points:
- the block not referring self!
- the httpconn class keeping copy of block, this:
chunkblock_ = [chunkblock copy];
edit
extra info: have verified if i'm freeing operation_ object deallocated fine:
reader.operation_ = nil; reader = nil; //previous line allows 'dealloc' called
now repeating question: operation did not pointer of reader's self, holds copy of block not refer self!
ok, i answer own question others not fall same problem. @darkdust correct. there tiny line ignoring:
**retriesnumber++;**
it looks innocent sentence, because retriesnumber member of class, meaning
(invisible strong pointer self)->retriesnumber
so solution declare property (versus member ivar) can use self access it, , write:
pself->retriesnumber++;
thank guys quick support, , hope others learn too!
Comments
Post a Comment