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:

  1. the block not referring self!
  2. the httpconn class keeping copy of block, this:

    chunkblock_ = [chunkblock copy];

explanation appreciated!

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

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -