Is there a leak in Apple's Scroll View Suite code sample?

I need help with Apple ScrollViewSuite code; in particular, I look at the ThumbImageView class, which does not have a specific dealloc method. I see in .h that the property for imageName uses persistence.

(I was not sure that I was allowed to publish any code from the moment it was created, so please let me know if I can / should.)

  • In any case, I thought that if we use save, we are responsible for releasing the reference to the object.

  • The CreateThumbScrollViewIfNecessary method (from the RootViewController implementation file) has a for loop that selects ThumbImageViews, sets a delegate, and then, after adding thumbview as a subtask to scrollview, continues to issue thumbview. If these objects are really freed, how does the delegate do his job, notifying when the image was clicked, scrolled, etc.

Sorry, I'm just so embarrassed. Any help would be greatly appreciated.

+4
source share
2 answers
  • You are responsible for clearing the object link. As far as I can tell, this Apple code will leak if this property is ever assigned a value.
  • Any view retains its routines. After each view has been added to scrollview, the class that creates it no longer uses it, so it frees the link. The object will not actually be freed until scrollview releases its link, so the views remain β€œalive” and can signal their delegates until this happens.
+2
source

Code leak. Unfortunately, the sample code with Apple samples usually leaves much to be desired, the design often sucks, and there are leaks and crashes. It’s best to use it only as an annotated API link that shows how the different parts of the API fit together, nothing more.

+4
source

Source: https://habr.com/ru/post/1344726/


All Articles