Coder Social home page Coder Social logo

Comments (5)

srdanrasic avatar srdanrasic commented on August 23, 2024

Thanks for the feedback Ian. Yeah, this'll need some improvement.

In addition to your suggestion, I'm thinking to allow option to retain observed NSObject by the Dynamic. Do you think that that might help in some situations?

from bond.

nayzak avatar nayzak commented on August 23, 2024

I think it would be more dangerous to retain observed NSObject by the Dynamic than to ask user to stop observing directly.
Now I'm working on tiny "mvvm" framework for my own use and I found many interesting ideas in SwiftBond project (but I think it little bit complex for my taste). So I tried to make an infinite scroll for UITableView and found that issue with removeObserver. Infinite scroll object had a Dynamic instance witch observed table's contentOffset. And when table view tried to deallocate itself an app was crashed because infinite scroll object was an instance value of UITableView (and also it's subview). So I made a special Dynamic class only for KVO with special method for removing itself from NSObject observers. And than I used it in willMoveToSuperview of infinite scroll object.
I'm not a person who knows many programming patterns and is able to make a good architecture. More of that I have only starter level of knowledge in iOS development. So I don't think that I could give you any advice at this point.

from bond.

srdanrasic avatar srdanrasic commented on August 23, 2024

Ok, I can see the problem. Please have in mind that Cocoa Touch does not officially support KVO on UIKit objects. It's just a coincidence it works. In your case, better approach would be to register your view controller as a delegate of your table view and implement method scrollViewDidScroll:.

UITableView is a subclass of UIScrollView and UITableViewDelegate inherits UIScrollViewDelegate so you can get offset change that way.

from bond.

nayzak avatar nayzak commented on August 23, 2024

Hm. Just made infinite scroll using Bond and KVO observing. It seems to be no issue if make the bond (contentOffset listener) equals to nil in right place.

from bond.

zdnk avatar zdnk commented on August 23, 2024

I am currently in the same situation. I have couple KVO observers, then values mapped to viewModel and those dynamics bound to UIViews. This all is wrapped in DynamicArray which when cleared (removeAll) causes crash

'An instance 0x1706690c0 of class BETPossibilityModel was deallocated while key value observers were still registered with it. Current observation info: (NSKeyValueObservationInfo 0x174458e10) (
)NSKeyValueObservance 0x1740d5540: Observer: 0x1740d54d0, Key path: name, Options: (New: YES, Old: NO, Prior: NO) Context: 0x0, Property: 0x174458d80)

How to fix this? :O

from bond.

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.