Skip to content

Commit

Permalink
Move info method to the right place
Browse files Browse the repository at this point in the history
  • Loading branch information
gcasa committed Sep 15, 2023
1 parent 1997793 commit 4b54990
Showing 1 changed file with 44 additions and 43 deletions.
87 changes: 44 additions & 43 deletions Source/NSKeyValueObserving.m
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,50 @@ - (void*) contextForObserver: (NSObject*)anObserver ofKeyPath: (NSString*)aPath
[iLock unlock];
return context;
}

- (void) removeObserver: (NSObject*)anObserver
forKeyPath: (NSString*)aPath
context: (void*)context
{
GSKVOPathInfo *pathInfo;

[iLock lock];
pathInfo = (GSKVOPathInfo*)NSMapGet(paths, (void*)aPath);
if (pathInfo != nil)
{
unsigned count = [pathInfo->observations count];

pathInfo->allOptions = 0;
while (count-- > 0)
{
GSKVOObservation *o;

o = [pathInfo->observations objectAtIndex: count];
if ((o->observer == anObserver || o->observer == nil) &&
(o->context == context))
{
[pathInfo->observations removeObjectAtIndex: count];
if ([pathInfo->observations count] == 0)
{
NSMapRemove(paths, (void*)aPath);
}
}
else
{
pathInfo->allOptions |= o->options;
}
}
}
[iLock unlock];
}

- (void)removeObserver:(NSObject *)observer
fromObjectsAtIndexes:(NSIndexSet *)indexes
forKeyPath:(NSString *)keyPath
context:(void *)context
{
}

@end

@implementation NSKeyValueObservationForwarder
Expand Down Expand Up @@ -1562,49 +1606,6 @@ - (void) removeObserver: (NSObject*)anObserver forKeyPath: (NSString*)aPath
}


- (void) removeObserver: (NSObject*)anObserver
forKeyPath: (NSString*)aPath
context: (void*)context
{
GSKVOPathInfo *pathInfo;

[kvoLock lock];
pathInfo = (GSKVOPathInfo*)NSMapGet(paths, (void*)aPath);
if (pathInfo != nil)
{
unsigned count = [pathInfo->observations count];

pathInfo->allOptions = 0;
while (count-- > 0)
{
GSKVOObservation *o;

o = [pathInfo->observations objectAtIndex: count];
if ((o->observer == anObserver || o->observer == nil) &&
(o->context == context))
{
[pathInfo->observations removeObjectAtIndex: count];
if ([pathInfo->observations count] == 0)
{
NSMapRemove(paths, (void*)aPath);
}
}
else
{
pathInfo->allOptions |= o->options;
}
}
}
[kvoLock unlock];
}

- (void)removeObserver:(NSObject *)observer
fromObjectsAtIndexes:(NSIndexSet *)indexes
forKeyPath:(NSString *)keyPath
context:(void *)context
{
}

@end

/**
Expand Down

0 comments on commit 4b54990

Please sign in to comment.