Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Jonathan 'Wolf' Rentzsch http://rentzsch.com

« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS 

Calculate a NSView's frame in QuickDraw coordinates

@interface NSView (frameAsQuickDrawRect)
- (Rect)frameAsQuickDrawRect;
@end
@implementation NSView (frameAsQuickDrawRect)
- (Rect)frameAsQuickDrawRect {
    NSRect  nsrect = [self convertRect:[self bounds] toView:[[self window] contentView]];
    float   windowHeight = NSHeight( [[[self window] contentView] frame] );
    
    float   nsrectHeight = NSHeight( nsrect );
    
    Rect qdrect;
    qdrect.top = windowHeight - (nsrect.origin.y + nsrectHeight);
    qdrect.left = nsrect.origin.x;
    qdrect.bottom = qdrect.top + nsrectHeight;
    qdrect.right = qdrect.left + NSWidth( nsrect );
    
    return qdrect;
}
@end

Dynamically Enable/Disable WebObjects SQL Logging

Sometimes you want to log generated SQL selectively, so popping -DEOAdaptorDebugEnabled=true on the command line of your app is verbose overkill. Here's how you can selectively enable and disable SQL logging:

NSLog.allowDebugLoggingForGroups(0x10000L);
// Do something that roundtrips the DB, like editingContext.saveChanges().
NSLog.refuseDebugLoggingForGroups(0x10000L);

Configure Log4J in a WebObjects app

(new DOMConfigurator()).doConfigure(resourceManager().inputStreamForResourceNamed("log4j.xml", "app", null), LogManager.getLoggerRepository());

Dynamically enable D2WTraceRuleFiringEnabled

NSLog.debug.setAllowedDebugLevel(NSLog.DebugLevelDetailed);
NSLog.allowDebugLoggingForGroups(NSLog.DebugGroupRules);
« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS