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

Mocking an object under observation

I am seeing an exception when mocking an object that is already under KVO observation. Here is a simplified example that shows the problem: [sourceObject addObserver:destinationObject forKeyPath:@"stringProperty" options:NSKeyValueObservingOptionNew…
drewag
  • 93,393
  • 28
  • 139
  • 128
0
votes
2 answers

Getting "observationInfo" in iOS 6 SDK changes retainCount of object

I need that instance of my class observe property of itself, so I set observing: [self addObserver:self forKeyPath:@"myProperty" options:NSKeyValueObservingOptionNew context:nil] And in dealloc simply check and remove observer: - (void)dealloc { …
0
votes
1 answer

KVC Collection Accessor + index 0 beyond bounds for empty array error

I have a mutable array property declared and synthesized: @property (nonatomic, strong) NSMutableArray *arrayOfTasks; I am using KVC collection Accessors for the same property and also I have other methods which will internally call this KVC…
0
votes
1 answer

Design assistance for MVC and KVO

I have data that is persisted on the device that needs to sync with my my server, in terms of design am I on the right track? I have a model with a method to return my local objects, let's call it [model objects]'; Within this method it returns the…
mkral
  • 4,065
  • 4
  • 28
  • 53
0
votes
6 answers

compare values in a hash and return the matching key

I'm trying to look through a hash and compare it's values to an existing string and then when the match is found I want to output its key. I trying to write this in a code block and output the result to the console. officer.name = "Dave" @hash = {…
RubyDude1012
  • 477
  • 1
  • 8
  • 14
0
votes
2 answers

iOS delegate issues with KVO

I have a method which sends out a request and has a delegate responder. The method is being called by a KVO responder. The code works fine when I call it from viewDidLoad, but when I make the request from the KVO method, it doesn't trigger the…
Dobler
  • 821
  • 2
  • 10
  • 23
0
votes
1 answer

How to get notified about every UIImage initialized througout a whole app lifecycle?

On one hand, I'm just curious. On the other, I have to count somehow the amount of images created (to trigger cleanup at some quantity). Unfortunately memory warnings notify me too late, the app gets terminated before I have any chance to react, so…
0
votes
1 answer

Remove Observer issue in KVO in ios

I have a table which is filled with an array of objects, which I am observing, and when I delete all the objects, I remove the observer , but the problem is that when I delete all the objects in array and then again start adding it to the array I…
Ranjit
  • 4,576
  • 11
  • 62
  • 121
0
votes
0 answers

Routing KVO changes

I don't like that KVO routes all changes to the same observeValueForKeyPath:ofObject:change:context: method. At the moment I have a large tree of if statements sending these "observations" to different methods. Is there already a way to specify a…
v_y
  • 225
  • 2
  • 9
0
votes
0 answers

User default change notification with an in-app purchase

I am implementing in-app purchased for my app. As such, I am using the product identifier format of com.companyname.product.feature. The product identifier is used for the in-app purchase (which is working fine in sandbox) and as a user default to…
johnnyspo
  • 619
  • 3
  • 7
  • 18
0
votes
1 answer

KVO and changing UI on value changed

If I add an observer to observe the "highlighted" property of a UILabel, can I make a change to another UIView within the observation callback block? ie: Am I guaranteed that this callback block will always execute on the main thread? Thanks!
Wise Shepherd
  • 2,228
  • 4
  • 31
  • 43
0
votes
1 answer

Core Data KVO count

Is possible to observe the count of some Item, say Users, in Core Data? I could do something like this. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleDataModelChange:)…
jdog
  • 10,351
  • 29
  • 90
  • 165
0
votes
1 answer

why is KVO not working on UIView subclass?

I have a UIView subclass which in turn has a contentView, declared as such in the public header: @property (nonatomic,retain)UIVivew* contentView; I'm trying to get KVO notifications whenever contentView's frame changes but the…
SaldaVonSchwartz
  • 3,769
  • 2
  • 41
  • 78
0
votes
2 answers

KVO: Apparently the same "effective" keyPath produce different results

I have struggled with the setup of KVO for a few hours and I managed to get it to work: This works: [self addObserver:self forKeyPath:@"session.loginState" options:0 context:nil]; This doesn't: [self addObserver:self.session…
Besi
  • 22,579
  • 24
  • 131
  • 223
0
votes
1 answer

Removing KVO from self

I'm registering for callbacks on for my NSOperationQueue like this: [self.queue addObserver:self forKeyPath:@"operationCount" options:NSKeyValueObservingOptionNew context:NULL]; Because I have an expirationhandler for the long task, I do this in…
Crystal
  • 28,460
  • 62
  • 219
  • 393