<?xml version='1.0'?>
<rss version='2.0'>
<channel>
	<title>MDH's Software Blog</title>
	<link>http://markdamonhughes.com/Blog</link>
	<description>Mark Damon Hughes</description>
	<language>en</language>
	<pubDate>Sat, 18 Dec 2010 00:07:00 GMT</pubDate>
	<lastBuildDate>Sat, 18 Dec 2010 00:07:00 GMT</lastBuildDate>
	<ttl>720</ttl>
	<item>
		<category>blog</category>
		<title>Site Restored</title>
		<link>http://markdamonhughes.com/Blog/?entry=blog/20101217_1707_Site_Restored.html</link>
		<guid>http://markdamonhughes.com/Blog/?entry=blog/20101217_1707_Site_Restored.html</guid>
		<description><![CDATA[
<p>Okay, site is restored. Comedy of errors problems resolved, shoemaker's children are now shod.
</p>
]]></description>
		<author>Mark Damon Hughes</author>
		<pubDate>Sat, 18 Dec 2010 00:07:00 GMT</pubDate>
	</item>
	<item>
		<category>cocoa</category>
		<title>Scripting in Xcode 4</title>
		<link>http://markdamonhughes.com/Blog/?entry=cocoa/20100723_1324_xcode4_scripting.html</link>
		<guid>http://markdamonhughes.com/Blog/?entry=cocoa/20100723_1324_xcode4_scripting.html</guid>
		<description><![CDATA[
<p>The new Xcode 4 beta is up at <a href="http://developer.apple.com/iphone/" target="_blank">ADC</a>, and I'm learning its quirks and changed keyboard keys, and just as quickly remapping them back to <a href="http://markdamonhughes.com/Blog/?entry=cocoa/20100327_1801_xcode_prefs.html" target="_blank">my keys</a>.
</p>

<p>But one thing is missing: Scripts, in particular my <a href="http://markdamonhughes.com/Blog/?entry=cocoa/20100327_1806_properties_and_accessors.html" target="_blank">accessors.py</a> script isn't available.
</p>

<p>There's a way to work around that, though: Services. If you open Automator, it'll prompt you to create a project. Pick Service, give it some recognizable name. Now choose Run Shell Script, click "Replaces selected text", type the path of your script (using $HOME for home, not ~), and save… And it's magically ready in the Services menu.
</p>

<p>To give it a key binding, you'll need to use System Preferences, Keyboard, Services. I'm not sure how (or if) you can change the category from Text to Development, but at least you can extend Xcode with scripts now.
</p>

<p><a href="http://markdamonhughes.com/Cocoa/" target="_blank">My Cocoa dev scripts</a>
</p>
]]></description>
		<author>Mark Damon Hughes</author>
		<pubDate>Fri, 23 Jul 2010 19:24:00 GMT</pubDate>
	</item>
	<item>
		<category>cocoa</category>
		<title>UIWebView Background</title>
		<link>http://markdamonhughes.com/Blog/?entry=cocoa/20100327_1808_uiwebview_background.html</link>
		<guid>http://markdamonhughes.com/Blog/?entry=cocoa/20100327_1808_uiwebview_background.html</guid>
		<description><![CDATA[
<dl>
<dt>Problem</dt>
	<dd><p>UIWebView leaves an ugly gray background when dragged up or down. You would like to have it show the view behind it instead (for performance and readability, please use a solid color or VERY simple pattern).
	</p>
	</dd>

<dt>Solution</dt>
	<dd><p>First, give the UIWebView clear background and non-opaque, either in IB or code:
	</p>
	<form><textarea class="code" cols="80" rows="3" readonly="readonly">
myWebView.backgroundColor=[UIColor clearColor];
myWebView.opaque=NO;
	</textarea></form>

	<p>Then make the page displayed have a clear background:
	</p>
	<form><textarea class="code" cols="80" rows="2" readonly="readonly">
<style>body { background-color: transparent; }</style>
	</textarea></form>

	</dd>

</dl>
]]></description>
		<author>Mark Damon Hughes</author>
		<pubDate>Sun, 28 Mar 2010 00:08:00 GMT</pubDate>
	</item>
	<item>
		<category>cocoa</category>
		<title>UIView Frames in GDB</title>
		<link>http://markdamonhughes.com/Blog/?entry=cocoa/20100327_1807_uiview_frames_in_gdb.html</link>
		<guid>http://markdamonhughes.com/Blog/?entry=cocoa/20100327_1807_uiview_frames_in_gdb.html</guid>
		<description><![CDATA[
<dl>
<dt>Problem</dt>
	<dd><p>When debugging display code, you want to see the frame of a component.
	</p>
	</dd>

<dt>Solution</dt>
	<dd><p>You can't directly display a CGRect in gdb, but you can use the NSStringFromCGRect() function:
	</p>
	<form><textarea class="code" cols="80" rows="2" readonly="readonly">
po NSStringFromCGRect((CGRect)[[self view] frame])
	</textarea></form>

	<p>See also the <a href="http://developer.apple.com/iPhone/library/documentation/UIKit/Reference/UIKitFunctionReference/Reference/reference.html" target="_blank">UIKit Function Reference</a> for many more useful functions.
	</dd>

</dl>

]]></description>
		<author>Mark Damon Hughes</author>
		<pubDate>Sun, 28 Mar 2010 00:07:00 GMT</pubDate>
	</item>
	<item>
		<category>cocoa</category>
		<title>Properties and Accessors</title>
		<link>http://markdamonhughes.com/Blog/?entry=cocoa/20100327_1806_properties_and_accessors.html</link>
		<guid>http://markdamonhughes.com/Blog/?entry=cocoa/20100327_1806_properties_and_accessors.html</guid>
		<description><![CDATA[
<dl>
<dt>Problem</dt>
	<dd><p>Creating a property takes up to 4 lines of repetitive code in Cocoa: The ivar declaration and @property in foo.h, @synthesize and dealloc in foo.m.
	</p>
	</dd>

<dt>Solution</dt>
	<dd><p>You can use the commercial product <a href="http://www.kevincallahan.org/software/accessorizer.html" target="_blank">Accessorizer</a>, which is very powerful, but too big and full of clicky buttons and switches for my needs. I just wanted a tool to do minimal analysis of ivars and give me the text, which I can copy into place.
	</p>
	<p>Download <a href="http://markdamonhughes.com/Cocoa/accessors.zip" target="_blank">accessors.py</a> and follow the instructions in the comments.
	</dd>

</dl>
]]></description>
		<author>Mark Damon Hughes</author>
		<pubDate>Sun, 28 Mar 2010 00:06:00 GMT</pubDate>
	</item>
	<item>
		<category>cocoa</category>
		<title>iPhone Provisioning Profiles</title>
		<link>http://markdamonhughes.com/Blog/?entry=cocoa/20100327_1805_iphone_provisioning_profiles.html</link>
		<guid>http://markdamonhughes.com/Blog/?entry=cocoa/20100327_1805_iphone_provisioning_profiles.html</guid>
		<description><![CDATA[
<dl>
<dt>Problem</dt>
	<dd><p>You install new certificates or mobileprovision profiles, but Xcode isn't picking them up.
	</p>
	</dd>

<dt>Solution</dt>
	<dd><p>Restart Xcode. It only correctly acquires new profiles at startup.
	</p>
	</dd>

</dl>

]]></description>
		<author>Mark Damon Hughes</author>
		<pubDate>Sun, 28 Mar 2010 00:05:00 GMT</pubDate>
	</item>
	<item>
		<category>cocoa</category>
		<title>Cocoa Macros</title>
		<link>http://markdamonhughes.com/Blog/?entry=cocoa/20100327_1804_cocoa_macros.html</link>
		<guid>http://markdamonhughes.com/Blog/?entry=cocoa/20100327_1804_cocoa_macros.html</guid>
		<description><![CDATA[
<dl>
<dt>Problem</dt>
	<dd><p>Some Cocoa methods and functions are just too verbose for normal use.
	</p>
	</dd>

<dt>Solution</dt>
	<dd><p>Add these to your Foo_Prefix.pch header (or to your own header which you import regularly):
	</p>
	<form><textarea class="code" cols="80" rows="36" readonly="readonly">
#ifdef DEBUG
	// DLOG ("Debug Log") takes a format argument and 0 or more args:
	// DLOG(@"");
	// DLOG(@"%d", x);
	// Displays [CLASSNAME METHODNAME]: before the provided log message, ONLY
	// if preprocessor value DEBUG is set.
	#define DLOG(fmt, ...) NSLog(@"%s: " fmt, __PRETTY_FUNCTION__, ##__VA_ARGS__)
#else
	#define DLOG(...)
#endif

// Use in -dealloc, to release and assign to nil at the same time.
// DO NOT use properties in dealloc or init, you will invoke side-effects!
// Use: DEALLOC(varname);
#define DEALLOC(_a_) { [_a_ release]; _a_ = nil; }

// The NSMakeFoo functions are named badly from the more common TYPEMake,
// as seen in CGPointMake, etc.
#define NSPointMake(_x_, _y_) NSMakePoint((_x_), (_y_))
#define NSRectMake(_x_, _y_, _w_, _h_) NSMakeRect((_x_), (_y_), (_w_), (_h_))
#define NSSizeMake(_x_, _y_) NSMakeSize((_x_), (_y_))
#define NSRangeMake(_start_, _len_) NSMakeRange((_start_), (_len_))

// I have a bad habit of forgetting the trailing nil in
// +[NSArray arrayWithObjects:] and +[NSDictionary dictionaryWithObjectsAndKeys:],
// since it's not required in +[NSString stringWithFormat:].
#define NSArrayMake(...) [NSArray arrayWithObjects:__VA_ARGS__, nil]
#define NSDictMake(...) [NSDictionary dictionaryWithObjectsAndKeys:__VA_ARGS__, nil]

// Short convenience constructors for NSNumber and NSString instances:
#define NSBoolMake(_a_) [NSNumber numberWithBool:(_a_)]
#define NSIntMake(_a_) [NSNumber numberWithInteger:(_a_)]
#define NSDoubleMake(_a_) [NSNumber numberWithDouble:(_a_)]
#define NSStringMake(_fmt_, ...) [NSString stringWithFormat:_fmt_, ##__VA_ARGS__]
	</textarea></form>

	<p>I'm "cheating" here, using NS prefixes for functions I created, not Apple. But using my own prefix would be very confusing for many of these.
	</dd>

</dl>
]]></description>
		<author>Mark Damon Hughes</author>
		<pubDate>Sun, 28 Mar 2010 00:04:00 GMT</pubDate>
	</item>
	<item>
		<category>cocoa</category>
		<title>New Project Checklist</title>
		<link>http://markdamonhughes.com/Blog/?entry=cocoa/20100327_1803_new_project.html</link>
		<guid>http://markdamonhughes.com/Blog/?entry=cocoa/20100327_1803_new_project.html</guid>
		<description><![CDATA[
<dl>
<dt>Problem</dt>
	<dd><p>Setting up a new Xcode project requires a few steps:
	</p>
	</dd>

<dt>Solution</dt>
	<dd><ul>
	<li>File|New Project, pick template, choose dir (~/Code/CodeTouch or ~/Code/CodeMac), enter name.</li>
	<li>Project|Edit Project Settings:
		<ul>
		<li>Build tab</li>
		<li>Configuration: <b>All Configurations</b></li>
		<li>Treat Warnings as Errors: <b>YES</b></li>
		<li>Configuration: <b>Debug</b></li>
		<li>Preprocessor Macros: double-click, +, <b>DEBUG=1</b></li>
		</ul>
	</li>
	</ul>
	</dd>

</dl>
]]></description>
		<author>Mark Damon Hughes</author>
		<pubDate>Sun, 28 Mar 2010 00:03:00 GMT</pubDate>
	</item>
	<item>
		<category>cocoa</category>
		<title>Code Snippet Organization</title>
		<link>http://markdamonhughes.com/Blog/?entry=cocoa/20100327_1802_code_snippets.html</link>
		<guid>http://markdamonhughes.com/Blog/?entry=cocoa/20100327_1802_code_snippets.html</guid>
		<description><![CDATA[
<dl>
<dt>Problem</dt>
	<dd><p>You have common code used in many projects, usually just bits and pieces. Storing it in text files or even Yojimbo or TextExpander is too much trouble and the code can get stale and no longer compile.
	</p>
	</dd>

<dt>Solution</dt>
	<dd><p>Create an Xcode project named "Clipboard". For every snippet, create a source file with just one method. Every time you add a snippet, Build|Clean and Build|Build.
	</p>
	</dd>

</dl>
]]></description>
		<author>Mark Damon Hughes</author>
		<pubDate>Sun, 28 Mar 2010 00:02:00 GMT</pubDate>
	</item>
	<item>
		<category>cocoa</category>
		<title>Xcode Preferences</title>
		<link>http://markdamonhughes.com/Blog/?entry=cocoa/20100327_1801_xcode_prefs.html</link>
		<guid>http://markdamonhughes.com/Blog/?entry=cocoa/20100327_1801_xcode_prefs.html</guid>
		<description><![CDATA[
<dl>
<dt>Problem</dt>
	<dd><p>The default layout and key bindings in Xcode are dysfunctional.
	</p>
	</dd>

<dt>Solution</dt>
	<dd><p>In Preferences|General (with NO project open): Layout: All-in-One. You can still double-click a file to open in a new window, but this default keeps you focused on ONE task at a time.
	</p>

	<p>In Preferences|Building: Build Results Open: Always. I set the filter dropdown to "Issues Only", but YMMV.
	</p>

	<p>In Preferences|Debugging: Debug on Start: Open Console. Seeing NSLog output is essential.
	</p>

	<p>In Preferences|Key Bindings, I set these:
	</p>
	<form><textarea class="code" cols="80" rows="5" readonly="readonly">
File|Close File		⌘W (Closes the active document, NOT the window)
File|Close Window	⇑⌘W (So I can't close the project by accident)
Project|Project		⌘1 (Main project view)
Run|Debugger		⌘2 (Debug/console view)
	</textarea></form>
	</dd>
]]></description>
		<author>Mark Damon Hughes</author>
		<pubDate>Sun, 28 Mar 2010 00:01:00 GMT</pubDate>
	</item>
</channel>
</rss>

