Questions tagged [key-value-observing]

Key-value Observing or KVO is a technology for observing changes in object properties.

1201 questions
0
votes
1 answer

iOS: Update mutable array and use KVO to see chaneg

I've looked at some other SO answers in regards to this and I thought I was implementing my code correctly but I am not getting results. I have a mutable array property - arrLocations. In my .m file, in viewDidLoad I set up an observer for it and…
PruitIgoe
  • 6,166
  • 16
  • 70
  • 137
0
votes
1 answer

How to remove KVO observer from tableViewCell?

I know this probably isn't best practice for MVC but I have an observer in my custom tableViewCell to know when I am expanded the cell or not (code below). When I press the back button on my nav bar, the app crashes with "An instance TableViewCell…
tahoecoop
  • 378
  • 2
  • 9
  • 30
0
votes
2 answers

Implement KVO pattern in UIButton-SWIFT

I am trying to observe the change in UIButton title using KVO pattern.Added observer in viewDidLoad. @IBOutlet weak var KVOBTn: UIButton! override func viewDidLoad() { super.viewDidLoad() KVOBTn.titleLabel!.addObserver(self, forKeyPath:…
user4790024
0
votes
1 answer

When an object is being instantiated, how can a BAD ACCESS occur when sending a NSKeyValueNotifyObserver message to a deallocated object

We have had this weird issue. When we instantiated an object, we also instantiate a property that belongs to that object: -(instancetype)init { self = [super init]; if (self) { [self setDocument]; } return…
A O
  • 5,516
  • 3
  • 33
  • 68
0
votes
1 answer

KVO not working for attribute of custom NSObject subclass

I'm writing an app that interfaces with Bluetooth, and for OO reasons I need to be able to notify 1 to many objects when Bluetooth events happen. I've got a custom Model object: class BluetoothModel: NSObject, CBCentralManagerDelegate { var…
0
votes
1 answer

KVO hassles whilst trying to stream-play a video using AV Foundation

Goal: I'm ultimately trying to read an external video file (.mp4, .mpg...); within an instance of AVPlayerViewController. But I'm having all sorts of KVO problems. AVPlayerViewController's KVO observer is always firing, even though I didn't…
Frederick C. Lee
  • 9,019
  • 17
  • 64
  • 105
0
votes
1 answer

Get multiple fields from entity in core data

I am trying to fetch multiple fields from a core data entity. Following code will work to fetch one field. What is syntax for two fields? NSMutableArray *areas = [[addresses valueForKey:@"area"] mutableCopy];
user1904273
  • 4,562
  • 11
  • 45
  • 96
0
votes
0 answers

Model object not being released after removing observer

My UIViewController has a UITableView. Each custom cell is given a model object with weak association. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { List *list =…
djibouti33
  • 12,102
  • 9
  • 83
  • 116
0
votes
2 answers

Registering a bool for a NSNotification

I'm trying to wrap my head around NSNotification but can't seem to get it to work. Think I'm misunderstanding how to register for an notification. I have a bool as a property in my connection manager class. At initialisation I authenticate with a…
Rudiger
  • 6,749
  • 13
  • 51
  • 102
0
votes
1 answer

KVO Method observeValueForKeyPath notifys me about the change, but I can't use it in viewDidLoad

I am working on this couple of days and I can't figure out what I am doing wrong. First, I don't know if the KVO is the best way to pass the value of the clicked row info from one view controller to another view controller. I have Main view, with 2…
user2417624
  • 653
  • 10
  • 32
0
votes
2 answers

How do I ensure proper KVO behaviour for my NSSlider-like custom control?

Let's say you have a custom control similar to NSSlider but with support for choosing a range of values, instead of a single value. The obvious choice of properties is minValue, maxValue, leftValue, rightValue, or however you wanna name them. You'd…
Regexident
  • 29,441
  • 10
  • 93
  • 100
0
votes
2 answers

Xcode how to detect a view's properties changed?

How can I detect a view's x,y,width or height is changed ? I want to implement that once a view's properties are changed, the other view's positions are reorganised. For example, I have a webview which has dynamic height. Each time…
Nijat2018
  • 863
  • 2
  • 10
  • 26
0
votes
2 answers

Using KVO with custom UITableViewCell and CoreData

I've read over a ton of documentation and tutorials about KVO but I haven't found any that I've been able to abstract for my application. I have a table view that uses a custom UITableViewCell class to provide an interface for turning options…
E-Madd
  • 4,414
  • 5
  • 45
  • 77
0
votes
1 answer

Receive KVO notifications for all property and changes recursively at top level

If I have the following data model: Model - subModels (NSMutableArray * of type SubModel) SubModel - text - createdAt is it possible to use KVO to observe changes on the parent Model class and still receive changes notifications for…
barndog
  • 6,975
  • 8
  • 53
  • 105
0
votes
1 answer

KVO. ObserveValueForKeyPAth is not called

I am not if this will work properly [[cr1.crossRoad.trafficLights objectForKey: [NSNumber numberWithInt:pedestrianTL]] addObserver:view forKeyPath:@"colorState" options:NSKeyValueObservingOptionNew context:nil]; The…
AOY
  • 355
  • 3
  • 22