开发者

How to release instance vars and then reuse them

开发者 https://www.devze.com 2023-03-31 03:39 出处:网络
I have an object in my app that is declared as an instance var. URLRequest * myRequest When I go to use this class I:开发者_JAVA技巧

I have an object in my app that is declared as an instance var.

URLRequest * myRequest

When I go to use this class I:开发者_JAVA技巧

myRequest = [[URLRequest alloc] init];

Then when I am done with it I:

[myRequest release];//or dealloc does the same

Here is the more of the code: https://gist.github.com/1177739 It's to much to past here.

However, when I go to use the class again, it goes though the alloc and init, but my app crashes.

pointer being freed was not allocated

I don't understand this because I alloc and init again. If I don't release, I get memory leaks in my app. Thanks


maybe your method

- (void)urlComplete:(NSNotification *)notification

is being called twice, set urlRequest to bill and then test that it is not nil at the beginning of you

- (void)urlComplete:(NSNotification *)notification

method

0

精彩评论

暂无评论...
验证码 换一张
取 消