Key-value Observing or KVO is a technology for observing changes in object properties.
Questions tagged [key-value-observing]
1201 questions
0
votes
2 answers
iOS: Adding a continuous listener to observe any changes on server
This might be very basic questions but I have spent enough time to explore the possible solutions. In my project, I am successfully getting status info via service request. I want to add a continuous observer for any state change on the server. I am…

Obj-Swift
- 2,802
- 3
- 29
- 50
0
votes
2 answers
Enable/disable a button based on count in NSMutableArray
I have a view controller with a button that I'd like to enable if myArray.count > 0. I got KVO working initially, but it doesn't update.
My button property declared here:
@property (strong, nonatomic) IBOutlet UIBarButtonItem *saveButton;
I'd like…

Adrian
- 16,233
- 18
- 112
- 180
0
votes
2 answers
KVO test in SWIFT
I have written a class in Swift for Lat/Long and I want to place the Location on the view controller. I am using KVO as a part of MVC. I am just trialing at the moment but why doesn't
func locationManager(manager: CLLocationManager!,…

Jason
- 1,057
- 3
- 13
- 31
0
votes
1 answer
Observing values for a primitive pointer
I have a class with a property
@property (nonatomic) double* myDoubles
This property has 3 doubles in it
myDoubles[0]; //0.02
myDoubles[1]; //0.42
myDoubles[2]; //0.99
If the values change, I'd like the following method to be called
[self…

Konrad Wright
- 1,254
- 11
- 24
0
votes
4 answers
How to implement KVO for readonly derived NSArray property?
I'd like to implement KVO for an NSArray property that is declared as readonly. The getter for this readonly property returns a copy of the private NSMutableArray that backs the backs the public readonly one:
In my .h:
@interface MyClass :…

Bibs
- 995
- 1
- 8
- 17
0
votes
1 answer
Key-Value Observer not changing on its own property
I am trying to get notifications for when a property called "currentTopViewPosition" changes. I used the following code to register for the changes and receive them:
[self addObserver:self
forKeyPath:@"currentTopViewPosition"…

Micaiah Wallace
- 1,101
- 10
- 17
0
votes
1 answer
Swift: which class owns the .New property used in NSObject.addObserver( ... options: .New )?
The current best practice for KVO in Swift is well documented in this SO post, and would look something like this:
someObject.addObserver( self, forKeyPath: "someProperty", options: .New,
context: &self.someContext )
I want to simplify memory…

Joseph Beuys' Mum
- 2,395
- 2
- 24
- 50
0
votes
0 answers
Upload in UiCollectionView Section
I have UICollectionView with 2 sections: first is the Upload Cells with its progress (and i need to remove it after uploading), second one has the all photos;
When im adding photo, i use KVO method
NSDictionary *uploadInfo = @{@"progress": progress,…

Матвей Козин
- 135
- 1
- 9
0
votes
1 answer
How to find out if a UITableViewCell has scrolled away and is invisible
I have a UITableViewCell that observes (via KVO) some properties. This only makes sense if the cell is visible. I want to remove this observer when the cell scrolls away, and before prepareForReuse is called.
How can I do this?

cfischer
- 24,452
- 37
- 131
- 214
0
votes
1 answer
what to do when a variable is not KVO-compliant?
I am trying to observe the property isDeviceConnected from the microsoft band api, but it seems to not be working, so I assume that it for some odd reason is not kvo-compliant. But how would I approach observing and responding to changes of a…

DevilInDisguise
- 360
- 1
- 4
- 14
0
votes
1 answer
iOS WatchKit - Adding Key Value Observer to NSUserDefaults crashes
I am trying to add the ability to send data from iPhone to Watch.
I have setup App Groups and everything runs smoothly, but when I try to add an observer to NSUserDefaults in the Watch Extension file, the app always crashes on startup.
(And yes, I…

JimmyJammed
- 9,598
- 19
- 79
- 146
0
votes
1 answer
how to udate window controls(NSTextField,NSCheckbox and etc) in binding manually
I am working on an application in which i need to store all the NSObject subclass properties into plist file and then allow users to store it and restore it. We call it profile and it can restore the saved state of all the controls/views on the…

AmitSri
- 1,209
- 1
- 20
- 48
0
votes
0 answers
With KVO in Objective-C is there a way to detect what observers my object has set on other objects?
Let there be an object A that observers a property on object B. Is there a way to ask A what properties it is observing and then see that it is observing a property on object B.
For for example:
[B addObserver:(A*)self…

Andrew Paul Simmons
- 4,334
- 3
- 31
- 39
0
votes
1 answer
KVO on Local Notifications
I'm updating a button based on if I have local notifications set on my iOS app. I'd like to do this with KVO, as there are various ways notifications can be set so I won't be easily able to track when a change is made to the local notifications…

Mark Bridges
- 8,228
- 4
- 50
- 65
0
votes
1 answer
Reactive Cocoa diferences between KVC and instance object
I use this code to subscribe events with my mutable array:
[RACObserve(self, marray) subscribeNext:^....
I am new in RAC and I don't understand why for example if I use:
NSMutableArray *keyValueCodingArray = [self…

Matrosov Oleksandr
- 25,505
- 44
- 151
- 277