Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
Brackets that don't close, oh no!
Source Link
Wowfunhappy
  • 268
  • 3
  • 11
if ([NSScroller preferredScrollerStyle] == NSScrollerStyleLegacy) { addPaddingForLegacyScrollbars(); 
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if ([[defaults objectForKey:@"AppleShowScrollBars"] isEqual: @"Always"]) { addPaddingForLegacyScrollbars(); 
if ([NSScroller preferredScrollerStyle] == NSScrollerStyleLegacy) { addPaddingForLegacyScrollbars(); 
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if ([[defaults objectForKey:@"AppleShowScrollBars"] isEqual: @"Always"]) { addPaddingForLegacyScrollbars(); 
if ([NSScroller preferredScrollerStyle] == NSScrollerStyleLegacy) addPaddingForLegacyScrollbars(); 
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if ([[defaults objectForKey:@"AppleShowScrollBars"] isEqual: @"Always"]) addPaddingForLegacyScrollbars(); 
added 16 characters in body
Source Link
Wowfunhappy
  • 268
  • 3
  • 11

Obviously, if this was my own code, I would rewrite it to use preferredScrollerStylepreferredScrollerStyle instead of NSUserDefaultsNSUserDefaults in the first place, but it's not, so I need to find acan only make changes at method boundaryboundaries.

Obviously, if this was my own code, I would rewrite it to use preferredScrollerStyle instead of NSUserDefaults in the first place, but it's not, so I need to find a method boundary.

Obviously, if this was my own code, I would rewrite it to use preferredScrollerStyle instead of NSUserDefaults in the first place, but it's not, so I can only make changes at method boundaries.

deleted 110 characters in body
Source Link
Wowfunhappy
  • 268
  • 3
  • 11

To fix this, I swizzledused the ZKSwizzle library to swizzle the NSUserDefaults objectForKey: method. Using the ZKSwizzle library:

On the other hand, monkey-patching someone else's code is an inherently weird thing to do, so I can accept that the optimal solution might be weird as well. Obviously, if this was my own code, I would rewrite it to use preferredScrollerStylepreferredScrollerStyle instead of NSUserDefaultsNSUserDefaults in the first place, but it's not, so I need to find a method boundary.

To fix this, I swizzled the NSUserDefaults objectForKey: method. Using the ZKSwizzle library:

On the other hand, monkey-patching someone else's code is an inherently weird thing to do, so I can accept that the optimal solution might be weird as well. Obviously, if this was my own code, I would rewrite it to use preferredScrollerStyle instead of NSUserDefaults in the first place.

To fix this, I used the ZKSwizzle library to swizzle the NSUserDefaults objectForKey: method:

Obviously, if this was my own code, I would rewrite it to use preferredScrollerStyle instead of NSUserDefaults in the first place, but it's not, so I need to find a method boundary.

added 28 characters in body
Source Link
Wowfunhappy
  • 268
  • 3
  • 11
Loading
added 28 characters in body
Source Link
Wowfunhappy
  • 268
  • 3
  • 11
Loading
Source Link
Wowfunhappy
  • 268
  • 3
  • 11
Loading