iphone - Is it safe to use the "hash" method to track NSURLConnections in memory? -
my question related discussion: http://www.cocoabuilder.com/archive/cocoa/202211-how-to-get-nsurl-form-nsurlconnection.html
i sending several nsurlconnections transmit data , need able tell specific connection failed or succeeded. there nsurldelegate methods (didfailwitherror, etc) return related nsurlconnection. problem there no nsurlrequest returned in delegate methods (and there no nsurl accessor in nsurlconnection).
the solution i've implemented maintain nsmutabledictionary pairs url string sent result of nsurlconnection's "hash" method.
i've tested , seems work - hash of nsurlconnection returned in delegate method same hash nsurlconnection sent initially.
my question: safe this? there better key use hash? i'm asking because in naive understanding, hash somehow associated address of object in memory, , seems possible backgrounding app or turning phone off , on may change value things rewritten memory.
thanks much!
i use asihttprequest, , when issuing multiple connections (concurrently in queue or parallel) use userinfo dictionary pass around context.
the "hash ivar" refer defined in nsobject protocol - method.  intended used in hash table, , such should sufficient needs.
i'd still prefer more first-class approach problem, whilst making more explicit request finishing/erroring-out.
Comments
Post a Comment