In my self-defined network handler function, I use a instance variable
"connection" to hold NSURLConnection alloced instance, when I will use
to load request, so the instance variable can be canceled some where.
and the instance will be released before next request performs.
that is,

if(connection){
[connection release];
}
connection = [[NSURLConnection alloc] initWithRequest:.....];
.......

I do not think the method that release connection in delegate's
message: connection:didFinishLoading, is a good form.
It  "MAY" cause EXEC_ACCESS_BAD, because I think if the instance was
released, where the delegate'message will return to?
eg, most of the instance to perfrom:
......
if(delegate && [delegate
respondsToSelector:@selector(connection:didFinishLoading)]){
     [delegate connection:self didFinishLoading];//will "self" be released??
}
///perhaps some more code
....


if the instance is released in delegate, what to perform the following
code?OK, maybe code segment will always be there, but if the code
access some instance vairable, it just will cause EXEC_ACCESS_BAD,
isn't it?


2010/8/13 Keary Suska <cocoa-...@esoteritech.com>:
> On Aug 12, 2010, at 1:41 PM, Conrad Shultz wrote:
>
>> On Aug 12, 2010, at 11:06, Keary Suska <cocoa-...@esoteritech.com> wrote:
>>
>>> If you really don't want (or can't have) an instance variable, you can 
>>> init/alloc then release in connectionDidFinishLoading: and 
>>> connection:didFailWithError:. I wouldn't recommend this though, as it is 
>>> probably "bad form", but as long you never want to memory-manage 
>>> NSURLConnections in that class, ever, it would be somewhat future proof.
>>
>> (First humble post - I will introduce myself properly when I have time to 
>> send out my own lingering Cocoa question.)
>>
>> Could you clarify why you think this paradigm is "bad form?" I only ask 
>> because as far as I can tell all of Apple's API docs follow said model. It 
>> seems like a good approach is to use init/alloc and still use an instance 
>> variable (to cancel the request, for example).
>
> The "bad form" paradigm is when you do *not* use an instance variable, or 
> some other means that allows reference within the class scope.
>
>> I also notice in the documentation that either of the init methods retain 
>> the delegate, whereas the class method is not documented as retaining the 
>> delegate. If my reading is correct, this will have design impact as well.
>
> Which is further reason why not having a reference to the instance could be 
> "bad idea". Retain cycle, anyone? Note also that retaining delegates is 
> inadvisable and should not be expected, hence the explicit documentation of 
> the behavior. A bug should be filed against the docs about the class 
> constructor--it either should indicate differing behavior or otherwise 
> indicate that it uses a specific instance init method.
>
> Keary Suska
> Esoteritech, Inc.
> "Demystifying technology for your home or business"
>
> _______________________________________________
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/sprhawk%40gmail.com
>
> This email sent to sprh...@gmail.com
>
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to