Comments (5)
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.
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.
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.
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.
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)
- Best way to interact with UIRefreshControl ?
- Cannot emulate VC lifecycle event HOT 1
- Feed() using collection view's sizeForItemAt delegate selector crashes on iOS 13
- MutableObservableArray2D replace items can't use performdiff
- Cocoapods latest version HOT 1
- Project file uses SRCROOT; should be PROJECT_DIR HOT 2
- Correct way to update MutableObservableArray2D from signals
- No (understandable) migration documentation for NSTableView binding
- Incorrect operator precedence in OutlineViewBinder.(_:,isExpandable:)
- Regarding .Framework file.
- Xcode build error: Header 'ReactiveKit-Swift.h' not found
- Cannot not build source code from the latest version on Xcode 12.3
- Wrong generic use of ObservableArray/MutableObservableArray?
- viewForSupplementaryElementOfKind and bidirectional binding HOT 1
- Control Event not triggered when setting data inside viewModel to textField
- Installation problems Xcode Version 12.4 (12D4e)
- Incorrect MutableObservableArray difference
- Error building app with Xcode 12.5 HOT 4
- Swift Package Manager Dynamic Libraries
- Unable to run in simulator on M1 Macs HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bond.