NSNibOutletConnector and NSNibControlConnector classes added

This commit is contained in:
Gregory John Casamento 2020-01-18 19:24:41 -05:00
parent f23058b172
commit c31ec536a2
4 changed files with 8 additions and 62 deletions

View file

@ -180,58 +180,3 @@
return desc;
}
@end
@implementation NSNibControlConnector
- (void) establishConnection
{
SEL sel = NSSelectorFromString(_tag);
[_src setTarget: _dst];
[_src setAction: sel];
}
@end
@implementation NSNibOutletConnector
- (void) establishConnection
{
NS_DURING
{
if (_src != nil)
{
NSString *selName;
SEL sel;
selName = [NSString stringWithFormat: @"set%@%@:",
[[_tag substringToIndex: 1] uppercaseString],
[_tag substringFromIndex: 1]];
sel = NSSelectorFromString(selName);
if (sel && [_src respondsToSelector: sel])
{
[_src performSelector: sel withObject: _dst];
}
else
{
/*
* We cannot use the KVC mechanism here, as this would always retain _dst
* and it could also affect _setXXX methods and _XXX ivars that aren't
* affected by the Cocoa code.
*/
const char *name = [_tag cString];
Class class = object_getClass(_src);
Ivar ivar = class_getInstanceVariable(class, name);
if (ivar != 0)
{
object_setIvar(_src, ivar, _dst);
}
}
}
}
NS_HANDLER
{
NSLog(@"Error while establishing connection %@: %@", self, [localException reason]);
}
NS_ENDHANDLER;
}
@end