开发者

iPhone Dev Objective-C - Object is being retained and I don't know where

开发者 https://www.devze.com 2023-03-18 16:49 出处:网络
I\'m creating an iPad game that has a viewController that loads in its view from a nib file. The view has a bunch of buttons in it, which I linked up to UIButton * variables via interface builder (so

I'm creating an iPad game that has a viewController that loads in its view from a nib file. The view has a bunch of buttons in it, which I linked up to UIButton * variables via interface builder (so each button is linked to a different variable). I checked the retain count right after they nib was loaded on one of the buttons (using my first button variable, b1) and it gives me a value of 2. Can anyone explain why it's 2? What are the two things that are retaining it right after the nib loads?

And now I'm even more confused because in my dealloc function, I released each of the button variable开发者_如何学Cs individually, and checked the retain count for one of them after and it's STILL 2! It should at least have gone down to 1, shouldn't it have? Should I release it several times in my dealloc function? If so, how many?

Thanks


Don't look at retain count.

Seriously.

Things other than you retain your stuff. Those numbers will move around underneath you for reasons that appear to make no sense, and then you'll come back here and post bewildered questions.

Just make sure your retains and releases balance. That's your only job.


If your IBOutlet properties are retained then you would have 1 retain there and another when the button gets added to the super view...

As Dan Ray says though, you shouldn't really worry about the retainCount...

0

精彩评论

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