<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: objc code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 15:47:55 GMT</pubDate>
    <description>DZone Snippets: objc code</description>
    <item>
      <title>How to draw your own table header... (with borders)</title>
      <link>http://snippets.dzone.com/posts/show/3931</link>
      <description>// It's a bit  hacky at the beginning, but nstableheadercell wasn't exactly making things easy for me&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;- (void)_drawThemeContents:(NSRect)cellFrame highlighted:(BOOL)highlighted inView:(NSTableHeaderView *)view;&lt;br /&gt;{&lt;br /&gt;	int index = [view columnAtPoint:NSMakePoint(cellFrame.origin.x + 1,cellFrame.origin.y + 1)];&lt;br /&gt;	NSRect headerRect;&lt;br /&gt;	if(index != -1)&lt;br /&gt;		headerRect = [view headerRectOfColumn:index];&lt;br /&gt;	else&lt;br /&gt;		headerRect = NSZeroRect;&lt;br /&gt;	&lt;br /&gt;	[headerImage drawInRect:cellFrame&lt;br /&gt;				   fromRect:NSZeroRect&lt;br /&gt;				  operation:NSCompositeSourceOver&lt;br /&gt;				   fraction:1.0];&lt;br /&gt;	&lt;br /&gt;	[[NSColor colorWithCalibratedRed:207.0/255.0&lt;br /&gt;							   green:207.0/255.0&lt;br /&gt;								blue:207.0/255.0&lt;br /&gt;							   alpha:1.0] set];&lt;br /&gt;	NSRectFill(NSMakeRect(headerRect.origin.x, headerRect.origin.y + 1, headerRect.size.width, headerRect.size.height - 2));&lt;br /&gt;	[headerImage drawInRect:NSMakeRect(headerRect.origin.x, headerRect.origin.y, headerRect.size.width - 1, headerRect.size.height)&lt;br /&gt;				   fromRect:NSZeroRect&lt;br /&gt;				  operation:NSCompositeSourceOver&lt;br /&gt;				   fraction:1.0];&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 28 Apr 2007 19:48:47 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3931</guid>
      <author>aptiva (Fj&#195;&#182;lnir &#195;?sgeirsson)</author>
    </item>
    <item>
      <title>How to make the system notify you of audio cd insertion</title>
      <link>http://snippets.dzone.com/posts/show/3856</link>
      <description>// Uses the DiskArbitration framework to notify ya of when new audio cds are inserted&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;NSDictionary *match = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"IOCDMedia", [NSNumber numberWithBool:YES], nil] forKeys:[NSArray arrayWithObjects:(NSString *)kDADiskDescriptionMediaKindKey, kDADiskDescriptionMediaWholeKey, nil]];&lt;br /&gt;		&lt;br /&gt;_session = DASessionCreate(kCFAllocatorDefault);&lt;br /&gt;DASessionScheduleWithRunLoop(_session, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);&lt;br /&gt;DARegisterDiskAppearedCallback(_session, (CFDictionaryRef)match, diskAppearedCallback, NULL);&lt;br /&gt;DARegisterDiskDisappearedCallback(_session, (CFDictionaryRef)match, diskDisappearedCallback, NULL);&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 23 Apr 2007 12:05:23 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3856</guid>
      <author>aptiva (Fj&#195;&#182;lnir &#195;?sgeirsson)</author>
    </item>
    <item>
      <title>Objective-C and Cocoa: Human-readable file size from number of bytes</title>
      <link>http://snippets.dzone.com/posts/show/3038</link>
      <description>// Returns a human-readable string showing the file size from the number of bytes&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;- (NSString *)stringFromFileSize:(int)theSize&lt;br /&gt;{&lt;br /&gt;	float floatSize = theSize;&lt;br /&gt;	if (theSize&lt;1023)&lt;br /&gt;		return([NSString stringWithFormat:@"%i bytes",theSize]);&lt;br /&gt;	floatSize = floatSize / 1024;&lt;br /&gt;	if (floatSize&lt;1023)&lt;br /&gt;		return([NSString stringWithFormat:@"%1.1f KB",floatSize]);&lt;br /&gt;	floatSize = floatSize / 1024;&lt;br /&gt;	if (floatSize&lt;1023)&lt;br /&gt;		return([NSString stringWithFormat:@"%1.1f MB",floatSize]);&lt;br /&gt;	floatSize = floatSize / 1024;&lt;br /&gt;&lt;br /&gt;	// Add as many as you like&lt;br /&gt;&lt;br /&gt;	return([NSString stringWithFormat:@"%1.1f GB",floatSize]);&lt;br /&gt;}&lt;/code&gt;</description>
      <pubDate>Sun, 26 Nov 2006 05:51:40 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3038</guid>
      <author>maximile (Max Williams)</author>
    </item>
    <item>
      <title>Calculate a NSView's frame in QuickDraw coordinates</title>
      <link>http://snippets.dzone.com/posts/show/918</link>
      <description>&lt;code&gt;@interface NSView (frameAsQuickDrawRect)&lt;br /&gt;- (Rect)frameAsQuickDrawRect;&lt;br /&gt;@end&lt;br /&gt;@implementation NSView (frameAsQuickDrawRect)&lt;br /&gt;- (Rect)frameAsQuickDrawRect {&lt;br /&gt;    NSRect  nsrect = [self convertRect:[self bounds] toView:[[self window] contentView]];&lt;br /&gt;    float   windowHeight = NSHeight( [[[self window] contentView] frame] );&lt;br /&gt;    &lt;br /&gt;    float   nsrectHeight = NSHeight( nsrect );&lt;br /&gt;    &lt;br /&gt;    Rect qdrect;&lt;br /&gt;    qdrect.top = windowHeight - (nsrect.origin.y + nsrectHeight);&lt;br /&gt;    qdrect.left = nsrect.origin.x;&lt;br /&gt;    qdrect.bottom = qdrect.top + nsrectHeight;&lt;br /&gt;    qdrect.right = qdrect.left + NSWidth( nsrect );&lt;br /&gt;    &lt;br /&gt;    return qdrect;&lt;br /&gt;}&lt;br /&gt;@end&lt;/code&gt;</description>
      <pubDate>Mon, 28 Nov 2005 14:34:31 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/918</guid>
      <author>rentzsch (Jonathan 'Wolf' Rentzsch)</author>
    </item>
  </channel>
</rss>
