Giter Site home page Giter Site logo

Comments (9)

jonathantribouharet avatar jonathantribouharet commented on May 3, 2024 1

From my experience, kvo is not a good thing to use in many case. In your code, it's even worse because the observer is the object itself. It's a ScrollView, you could just override layoutSubviews.
Still, this feature is not part of this library, it's like you add a code for have rounded border, it doesn't require to be in he library for work.

from jtcalendar.

yuriferretti avatar yuriferretti commented on May 3, 2024

Hi @f33chobits I used this code and its crashing on deallocation because the KVO observers added to observe contentOffset property aren't deallocated correctly. I saw that your code correctly remove the observers on dealloc methods but the object observed is nil on dealloc call, leading to removeObserver:forKeyPath not being executed.

from jtcalendar.

WenchaoD avatar WenchaoD commented on May 3, 2024

Hey @yuriferretti .
Sorry I forgot to submit my fixing to this. This problem would come up because the menuView would call dealloc ahead of menuMonthView (parent view first). So I fixed this by enumerating and removing observers in menuView. But that shouldn't be right. I think I should use NSNotificationCenter instead, which would decouple the dependence bettween menuView and menuMonthView. What do you think about this?

from jtcalendar.

WenchaoD avatar WenchaoD commented on May 3, 2024

#52 implement a better way. The menuView only has one observer this time.

from jtcalendar.

jonathantribouharet avatar jonathantribouharet commented on May 3, 2024

Sorry, but i cannot accept this pull request for 2 reasons:

  • first, you can just add a view over the JTCalendarMenuView which can reproduce the same effect, it will be cleaner and simpler
  • i will never accept a code with a try catch

from jtcalendar.

WenchaoD avatar WenchaoD commented on May 3, 2024

Try catch is indeed a bad solution, but is there another way to check whether there is an kvo observer yet?

from jtcalendar.

WenchaoD avatar WenchaoD commented on May 3, 2024

layoutSubviews is great! Thanks πŸ‘

from jtcalendar.

yuriferretti avatar yuriferretti commented on May 3, 2024

@f33chobits I just moved your KVO observing code to JTCalendarMenuView's private method configureConstraintsForSubviews as @jonathantribouharet mentioned and it's working like a charm!!

from jtcalendar.

WenchaoD avatar WenchaoD commented on May 3, 2024

πŸ‘

from jtcalendar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.