Skip to content

Commit

Permalink
Update to make the code a bit tighter, per suggestion by @fredkiefer
Browse files Browse the repository at this point in the history
  • Loading branch information
gcasa committed Aug 31, 2023
1 parent d596150 commit 5737e86
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions Source/GSXib5KeyedUnarchiver.m
Original file line number Diff line number Diff line change
Expand Up @@ -3169,36 +3169,40 @@ - (void) addOrderedObject: (GSXibElement*)element
}
}

- (id) decodeObjectForXib: (GSXibElement*)element
forClassName: (NSString*)classname
withID: (NSString*)objID
- (void) addToolTip: (GSXibElement *)element forObject: (id)object
{
// Try decoding the object using super first...
id object = [super decodeObjectForXib: element forClassName: classname withID: objID];

[self addOrderedObject: element];

NSString *toolTipString = [element attributeForKey: @"toolTip"];

// Process tooltips...
if ([element attributeForKey: @"toolTip"])
if (toolTipString == nil)
{
if ([object respondsToSelector: @selector(setToolTip:)])
[object setToolTip: [element attributeForKey: @"toolTip"]];
else if ([object respondsToSelector: @selector(setHeaderToolTip:)])
[object setHeaderToolTip: [element attributeForKey: @"toolTip"]];
GSXibElement *toolTipElement = [element elementForKey: @"toolTip"];

toolTipString = [toolTipElement value];
}
else if ([element elementForKey: @"toolTip"])

if (toolTipString != nil)
{
GSXibElement *toolTipElement = [element elementForKey: @"toolTip"];
NSString *v = [toolTipElement value];
if ([object respondsToSelector: @selector(setToolTip:)])
{
[object setToolTip: v];
[object setToolTip: toolTipString];
}
else if ([object respondsToSelector: @selector(setHeaderToolTip:)])
{
[object setHeaderToolTip: v];
[object setHeaderToolTip: toolTipString];
}
}
}

- (id) decodeObjectForXib: (GSXibElement*)element
forClassName: (NSString*)classname
withID: (NSString*)objID
{
// Try decoding the object using super first...
id object = [super decodeObjectForXib: element forClassName: classname withID: objID];

[self addOrderedObject: element];
[self addToolTip: element forObject: object];

// Process IB runtime attributes for element...
// Ensure we don't process the placeholders...
Expand Down

0 comments on commit 5737e86

Please sign in to comment.