<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SteveX Compiled &#187; Uncategorized</title>
	<atom:link href="http://blog.stevex.net/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.stevex.net</link>
	<description>Software development and other notes.</description>
	<lastBuildDate>Tue, 24 Jan 2012 00:39:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Can&#8217;t Connect to Lion SMB Share?</title>
		<link>http://blog.stevex.net/2012/01/cant-connect-to-lion-smb-share/</link>
		<comments>http://blog.stevex.net/2012/01/cant-connect-to-lion-smb-share/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 13:49:11 +0000</pubDate>
		<dc:creator>stevex</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.stevex.net/?p=1968</guid>
		<description><![CDATA[I&#8217;d been having this problem for a while and decided to dig into it today. I have shares from a Lion box, but when I&#8217;d attempt to connect from Windows 7, it would just refuse my credentials. Here&#8217;s the solution that worked for me. Edit this file in a text editor: /Library/Preferences/SystemConfiguration/com.apple.smb.server.plist You&#8217;ll need permissions [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;d been having this problem for a while and decided to dig into it today.  I have shares from a Lion box, but when I&#8217;d attempt to connect from Windows 7, it would just refuse my credentials.</p>
<p>Here&#8217;s the solution that worked for me.</p>
<p>Edit this file in a text editor:</p>
<pre>/Library/Preferences/SystemConfiguration/com.apple.smb.server.plist</pre>
<p>You&#8217;ll need permissions to edit it.  Run your editor using sudo, for example.</p>
<p>Add the following keys:</p>
<div class="codecolorer-container text dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;key&gt;AllowKerberosAuth&lt;/key&gt;<br />
&lt;true/&gt;<br />
&lt;key&gt;AllowNTLM2Auth&lt;/key&gt;<br />
&lt;true/&gt;<br />
&lt;key&gt;KerberosRealm&lt;/key&gt;<br />
&lt;string&gt;***COPY-THE-LocalKerberosRealm-VALUE***&lt;/string&gt;</div></td></tr></tbody></table></div>
<p>Don&#8217;t forget to edit this to copy the LocalKerberosRealm value into the KerberosRealm value.</p>
<p>Once you&#8217;ve done this, save the file, turn SMB sharing off and back on, and you should be able to log in.  I&#8217;m not convinced this is &#8220;the fix&#8221; for everybody, but it worked for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stevex.net/2012/01/cant-connect-to-lion-smb-share/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What do people eat?</title>
		<link>http://blog.stevex.net/2012/01/what-do-people-eat/</link>
		<comments>http://blog.stevex.net/2012/01/what-do-people-eat/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 13:30:56 +0000</pubDate>
		<dc:creator>stevex</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.stevex.net/?p=1965</guid>
		<description><![CDATA[Here&#8217;s an interesting way of looking at what people eat: Looking at what people do calorie queries for on Google. The winners are: apple banana almonds avocado beer banana broccoli blueberries chicken breast chicken coffee carrots dates domino's pizza dried apricot dried cranberries egg egg whites edamame eggplant fruit fish flour grapes grapefruit gin green [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s an interesting way of looking at what people eat:  Looking at what people do calorie queries for on Google.</p>
<p><img src="http://blog.stevex.net/files/2012/01/201201130836.jpg" height="100" width="513" border="1" hspace="4" vspace="4" alt="201201130836" /></p>
<p>The winners are:</p>
<table border="1">
<tr>
<td>
<pre>apple
banana
almonds
avocado
beer
banana
broccoli
blueberries
chicken breast
chicken
coffee
carrots
dates
domino's pizza
dried apricot
dried cranberries
egg
egg whites
edamame
eggplant
fruit
fish
flour
grapes
grapefruit</pre>
</td>
<td>
<pre>gin
green beans
honey
hummus
hard boiled egg
ham
ice cream
indian food
iceberg lettuce
italian sausage
jello
jelly beans
jack daniels
jujubes
kiwi
kale
kfc
kraft dinner
lettuce
lasagna
lean ground beef
lentils
milk
mcdonalds
mushrooms</pre>
</td>
<td>
<pre>mashed potatoes
nuts
naan
nanaimo bar
nachos
orange
oatmeal
one egg
onion
pizza
popcorn
pumpkin seeds
pomegranate
quinoa
quiznos
quiche
red wine
rice
raspberries
rum
sushi
sweet potato
salmon
sugar
tim hortons</pre>
</td>
<td valign="top">
<pre>turkey
tomato
tea
udon
unsweetened applesauce
vodka
vegetables
wine
white wine
watermelon
walnuts
xylitol
xanthan gum
xenergy
yogurt
yam
yellow pepper
zucchini</pre>
</td>
</tr>
</table>
<p>There you have it; a list of foods that&#8217;s not really much use for anything.  But still interesting.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stevex.net/2012/01/what-do-people-eat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apple Analysts</title>
		<link>http://blog.stevex.net/2012/01/apple-analysts/</link>
		<comments>http://blog.stevex.net/2012/01/apple-analysts/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 13:23:49 +0000</pubDate>
		<dc:creator>stevex</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.stevex.net/?p=1961</guid>
		<description><![CDATA[It&#8217;s amazing the discongruity between the &#8220;professional&#8221; analysts of Apple&#8217;s financials, and the &#8220;amateurs&#8221; like Horace Dediu of Asymco. I put &#8220;professional&#8221; and &#8220;amateur&#8221; in quotes because it seems like in this case, the results you get from these two groups are opposite from what you&#8217;d expect. The financial market, and professional analysts, have been [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s amazing the discongruity between the &#8220;professional&#8221; analysts of Apple&#8217;s financials, and the &#8220;amateurs&#8221; like  Horace Dediu of <a href="http://www.asymco.com/">Asymco</a>.</p>
<p>I put &#8220;professional&#8221; and &#8220;amateur&#8221; in quotes because it seems like in this case, the results you get from these two groups are opposite from what you&#8217;d expect.  The financial market, and professional analysts, have been underestimating Apple for years now.  </p>
<p>This story at Market Watch, &#8220;<a href="http://www.marketwatch.com/story/time-to-sell-apple-2012-01-12?dist=beforebell">Time to Sell Apple</a>&#8220;, is a perfect example.  Here&#8217;s a few points from this article.</p>
<blockquote><p>If a business fails to take care of its customers, its customers will go elsewhere … In the case of Apple, this is happening in front of our eyes, and the risks are therefore very high. Apple has stopped serving their customers well, and unless they start to serve their customers better the company will begin to lose more market share and revenue and earnings projections will come down aggressively.</p></blockquote>
<p>But this whole statement is based on this assertion:</p>
<blockquote><p>Most people think Apple&#8217;s customers are the end user, but … the real customers are third-party resellers, and Apple is not treating them right.</p></blockquote>
<p>This is just flat out wrong.  Apple has never pandered to the carriers and resellers.  They&#8217;re the only phone manufacturer that doesn&#8217;t, and it&#8217;s one of the reason their real customers, the folks using the phones, prefer their products.</p>
<p>iPhone users are people who want an iPhone.  Android users are, mostly, people who want a phone, and went with the one the carrier suggested.</p>
<blockquote><p>The company&#8217;s high-growth phase is behind it</p></blockquote>
<p>This is where the analysts methods fail.  They can only analyze the data they have available, and they have no data about future products.  But it&#8217;s these future products, the ones we don&#8217;t know about yet, that is where Apple&#8217;s growth comes from.   </p>
<p>I don&#8217;t think the market has any model that can account for this, so they look at each new, incredibly successful, incredibly profitable thing that Apple does as if it&#8217;s the last one.  Because how could they do otherwise?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stevex.net/2012/01/apple-analysts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An Apple TV</title>
		<link>http://blog.stevex.net/2012/01/an-apple-tv/</link>
		<comments>http://blog.stevex.net/2012/01/an-apple-tv/#comments</comments>
		<pubDate>Tue, 03 Jan 2012 21:47:24 +0000</pubDate>
		<dc:creator>stevex</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.stevex.net/?p=1955</guid>
		<description><![CDATA[I don&#8217;t really understand why Apple would get into the TV business. Apple creates new markets. Moving into an established market like the TV business, with all the content complexity and interconnection requirements, just doesn&#8217;t seem like something they&#8217;d do. It&#8217;s a highly competitive space with low margins; not Apple&#8217;s kind of business. And the [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t really understand why Apple would get into the TV business.</p>
<p>Apple creates new markets.  Moving into an established market like the TV business, with all the content complexity and interconnection requirements, just doesn&#8217;t seem like something they&#8217;d do.  It&#8217;s a highly competitive space with low margins; not Apple&#8217;s kind of business.</p>
<p>And the idea that the world needs an Apple TV because TVs are too hard to connect seems off the mark.  Hooking up a TV isn&#8217;t difficult; it&#8217;s hooking up all the other devices &#8211; the cable box, the PS3, the Xbox 360 with the Kinect, the Wii and its sensor bar, that make it difficult.  Unless Apple is planning to take over the jobs that all the other devices people do with things hooked up to their TVs, they&#8217;re not going to be making things that much simpler.</p>
<p>An &#8220;Apple TV&#8221; without some pretty amazing content deals would still require a cable box, and if they could pull off those deals, why tie it to a new TV?  Why not just making it available through the Apple TV for everyone?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stevex.net/2012/01/an-apple-tv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UITableView selection not sticking when reloading cells</title>
		<link>http://blog.stevex.net/2011/12/uitableview-selection-not-sticking-when-reloading-cells/</link>
		<comments>http://blog.stevex.net/2011/12/uitableview-selection-not-sticking-when-reloading-cells/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 03:31:13 +0000</pubDate>
		<dc:creator>stevex</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.stevex.net/2011/12/uitableview-selection-not-sticking-when-reloading-cells/</guid>
		<description><![CDATA[I have some UITableView code that was setting a selection, and then later making some other changes to the cell using reloadRowsAtIndexPaths:withRowAnimation: and I was having trouble figuring out why my selection wasn&#8217;t sticking. I&#8217;d select an object, but it wouldn&#8217;t show as selected. Turns out reloadRowsAtIndexPaths:withRowAnimation: will deselect whatever rows you reload. Check this [...]]]></description>
			<content:encoded><![CDATA[<p>I have some UITableView code that was setting a selection, and then later making some other changes to the cell using <a href="http://developer.apple.com/library/ios/documentation/uikit/reference/UITableView_Class/Reference/Reference.html#//apple_ref/occ/instm/UITableView/reloadRowsAtIndexPaths:withRowAnimation:">reloadRowsAtIndexPaths:withRowAnimation:</a> and I was having trouble figuring out why my selection wasn&#8217;t sticking.  I&#8217;d select an object, but it wouldn&#8217;t show as selected.</p>
<p>Turns out reloadRowsAtIndexPaths:withRowAnimation: will deselect whatever rows you reload.  Check this out:</p>
<div class="codecolorer-container objc dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #11740a; font-style: italic;">// Create an NSIndexPath that indicates the 3rd row</span><br />
<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/"><span style="color: #400080;">NSIndexPath</span></a> <span style="color: #002200;">*</span>path <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/"><span style="color: #400080;">NSIndexPath</span></a> indexPathForRow<span style="color: #002200;">:</span><span style="color: #2400d9;">3</span> inSection<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#93;</span>;<br />
<br />
<span style="color: #11740a; font-style: italic;">// Select it</span><br />
<span style="color: #002200;">&#91;</span>self.tableView selectRowAtIndexPath<span style="color: #002200;">:</span>path<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; animated<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scrollPosition<span style="color: #002200;">:</span>UITableViewScrollPositionNone<span style="color: #002200;">&#93;</span>;<br />
<br />
<span style="color: #11740a; font-style: italic;">// Is it still selected? &nbsp; &nbsp;</span><br />
path <span style="color: #002200;">=</span> self.tableView.indexPathForSelectedRow;<br />
<br />
<span style="color: #11740a; font-style: italic;">// Yes, this will print the values you'd expect for that row being selected</span><br />
NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Path: %@&quot;</span>, path<span style="color: #002200;">&#41;</span>;<br />
<br />
<span style="color: #11740a; font-style: italic;">// Reload that row</span><br />
<span style="color: #002200;">&#91;</span>self.tableView reloadRowsAtIndexPaths<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a> arrayWithObject<span style="color: #002200;">:</span>path<span style="color: #002200;">&#93;</span> withRowAnimation<span style="color: #002200;">:</span>UITableViewRowAnimationNone<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <br />
<span style="color: #11740a; font-style: italic;">// Now is it still selected?</span><br />
path <span style="color: #002200;">=</span> self.tableView.indexPathForSelectedRow;<br />
<br />
<span style="color: #11740a; font-style: italic;">// Negatory, path is null.</span><br />
NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Path: %@&quot;</span>, path<span style="color: #002200;">&#41;</span>;</div></td></tr></tbody></table></div>
<p>It&#8217;s not obvious from the documentation that this operation affects the selection, and it took me a while to figure out why my selection was being dropped.  The fix is simple enough:  Preserve the selection yourself around the reload call.</p>
<div class="codecolorer-container objc dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #11740a; font-style: italic;">// Save the current selection</span><br />
<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/"><span style="color: #400080;">NSIndexPath</span></a> <span style="color: #002200;">*</span>savedSelection <span style="color: #002200;">=</span> self.tableView.indexPathForSelectedRow;<br />
<br />
<span style="color: #11740a; font-style: italic;">// Reload</span><br />
<span style="color: #002200;">&#91;</span>self.tableView reloadRowsAtIndexPaths<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a> arrayWithObject<span style="color: #002200;">:</span>path<span style="color: #002200;">&#93;</span> withRowAnimation<span style="color: #002200;">:</span>UITableViewRowAnimationNone<span style="color: #002200;">&#93;</span>;<br />
<br />
<span style="color: #11740a; font-style: italic;">// And restore the selection</span><br />
<span style="color: #002200;">&#91;</span>self.tableView selectRowAtIndexPath<span style="color: #002200;">:</span>savedSelection<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; animated<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scrollPosition<span style="color: #002200;">:</span>UITableViewScrollPositionNone<span style="color: #002200;">&#93;</span>;</div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.stevex.net/2011/12/uitableview-selection-not-sticking-when-reloading-cells/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a UIView with a Tiled Background</title>
		<link>http://blog.stevex.net/2011/12/creating-a-uiview-with-a-tiled-background/</link>
		<comments>http://blog.stevex.net/2011/12/creating-a-uiview-with-a-tiled-background/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 03:01:31 +0000</pubDate>
		<dc:creator>stevex</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.stevex.net/?p=1928</guid>
		<description><![CDATA[Tiling a background texture is a pretty common thing to want to do. Instead of creating one large texture that fills the entire background, instead the goal is to take a smaller image, say 256&#215;256, and repeat it horizontally and vertically to fill the background. As far as I can tell, there&#8217;s no way to [...]]]></description>
			<content:encoded><![CDATA[<p>Tiling a background texture is a pretty common thing to want to do.  Instead of creating one large texture that fills the entire background, instead the goal is to take a smaller image, say 256&#215;256, and repeat it horizontally and vertically to fill the background.  </p>
<p>As far as I can tell, there&#8217;s no way to do this in Interface Builder.  You can create a UIImageView to use as the background of a view, but the options for placing the image don&#8217;t include tiling.  </p>
<p>Turns out tiling is just a special kind of colour.</p>
<div class="codecolorer-container objc dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">UIImage <span style="color: #002200;">*</span>image <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIImage imageWithContentsOfFile<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/"><span style="color: #400080;">NSBundle</span></a> mainBundle<span style="color: #002200;">&#93;</span> pathForResource<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;corkboard&quot;</span> ofType<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;png&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;<br />
self.backgroundColor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIColor colorWithPatternImage<span style="color: #002200;">:</span>image<span style="color: #002200;">&#93;</span>;</div></td></tr></tbody></table></div>
<p>This loads an image called &#8220;corkboard.png&#8221; and sets it as a repeating pattern by using it as the view&#8217;s backgroundColor.  The colour itself is a special kind of &#8220;colour&#8221; that&#8217;s actually the image itself, repeating over whatever space the color needs to fill.</p>
<p>Not a bad way to do it, but the odd location makes it a bit hard to discover.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stevex.net/2011/12/creating-a-uiview-with-a-tiled-background/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UIManagedDocument autosave troubleshooting</title>
		<link>http://blog.stevex.net/2011/12/uimanageddocument-autosave-troubleshooting/</link>
		<comments>http://blog.stevex.net/2011/12/uimanageddocument-autosave-troubleshooting/#comments</comments>
		<pubDate>Sun, 04 Dec 2011 03:33:41 +0000</pubDate>
		<dc:creator>stevex</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.stevex.net/?p=1926</guid>
		<description><![CDATA[I&#8217;d been having some trouble with UIManagedDocument that turned out to be my fault, but it wasn&#8217;t easy to figure out. In the end there were a couple of things that helped me figure out what was going on, so I&#8217;m posting them here in the hopes that I&#8217;ll save someone else some time. UIManagedDocument [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;d been having some trouble with UIManagedDocument that turned out to be my fault, but it wasn&#8217;t easy to figure out.  In the end there were a couple of things that helped me figure out what was going on, so I&#8217;m posting them here in the hopes that I&#8217;ll save someone else some time.</p>
<p>UIManagedDocument is a UIDocument subclass which stores document data in a Core Data database.  UIDocument is a class that manages document storage for you, but provides some great features like iCloud integration and automatic saving.</p>
<p>It&#8217;s the automatic saving that I was having trouble with.  I would create my UIManagedDocument subclass, create a new document, populate it, and all seemed well.  But then later, I&#8217;d create a new instance of a managed object, add it to my document, expect it to automatically save.. but it wasn&#8217;t saving.</p>
<p>Core Data is fairly well documented, and the process of creating a UIManagedDocument is also well documented, so I&#8217;m not going to post a whole walkthrough here.  To make autosave work, the key thing you need to do is either add something to the document&#8217;s undo manager, or use updateChangeCount to inform the document that you&#8217;ve made a change.  I was doing the latter.</p>
<p>The first thing I found useful was to subclass UIManagedDocument, and add an override:</p>
<div class="codecolorer-container objc dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>contentsForType<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>typeName error<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSError_Class/"><span style="color: #400080;">NSError</span></a> <span style="color: #002200;">*</span>__autoreleasing <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>outError<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Auto-Saving Document&quot;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>super contentsForType<span style="color: #002200;">:</span>typeName error<span style="color: #002200;">:</span>outError<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span></div></td></tr></tbody></table></div>
<p>You don&#8217;t want to leave NSLog messages in a shipping release binary, so do something about that, but the goal here is to know when the save is happening.  One reason for this is if you make a change to the document, and then kill the app before the change is autosaved, it doesn&#8217;t get saved.  Seeing the save in the console is your sign that you can kill the debug session knowing your change has been committed.</p>
<p>The other thing you need to know is when errors happen.  When UIManagedDocument runs into a Core Data error, your only opportunity to find out is through an override:</p>
<div class="codecolorer-container objc dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>handleError<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSError_Class/"><span style="color: #400080;">NSError</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>error userInteractionPermitted<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>userInteractionPermitted<br />
<span style="color: #002200;">&#123;</span> &nbsp; <br />
&nbsp; &nbsp; NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;UIManagedDocument error: %@&quot;</span>, error.localizedDescription<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/"><span style="color: #400080;">NSArray</span></a><span style="color: #002200;">*</span> errors <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>error userInfo<span style="color: #002200;">&#93;</span> objectForKey<span style="color: #002200;">:</span>NSDetailedErrorsKey<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>errors <span style="color: #002200;">!=</span> <span style="color: #a61390;">nil</span> <span style="color: #002200;">&amp;&amp;</span> errors.count &gt; <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSError_Class/"><span style="color: #400080;">NSError</span></a> <span style="color: #002200;">*</span>error <span style="color: #a61390;">in</span> errors<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot; &nbsp;Error: %@&quot;</span>, error.userInfo<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot; &nbsp;%@&quot;</span>, error.userInfo<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
<span style="color: #002200;">&#125;</span></div></td></tr></tbody></table></div>
<p>Without this override, your auto-save may fail, and you&#8217;ll never know about it.  In my case, I was getting a 1570 error, which, when looked up <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/CoreDataFramework/Miscellaneous/CoreData_Constants/Reference/reference.html">here</a>, turns out to be a missing mandatory property:  I forgot to set a mandatory property on one of my objects, so the save was failing and I had no idea until adding this override.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stevex.net/2011/12/uimanageddocument-autosave-troubleshooting/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Objective C Categories</title>
		<link>http://blog.stevex.net/2011/11/objective-c-categories/</link>
		<comments>http://blog.stevex.net/2011/11/objective-c-categories/#comments</comments>
		<pubDate>Sun, 27 Nov 2011 05:49:51 +0000</pubDate>
		<dc:creator>stevex</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.stevex.net/?p=1904</guid>
		<description><![CDATA[Categories take a little getting used to. Objective-C categories let you add your own functionality to existing classes. This can take classes in directions that seem decidedly strange. For example, if you want to draw a string in UIKit, you ask the string to draw itself. Coming from a Windows / Java background this seems [...]]]></description>
			<content:encoded><![CDATA[<p>Categories take a little getting used to.</p>
<p>Objective-C categories let you add your own functionality to existing classes.  This can take classes in directions that seem decidedly strange.</p>
<p>For example, if you want to draw a string in UIKit, you ask the string to draw itself.  Coming from a Windows / Java background this seems weird.  Why would a string know how to draw itself into a graphics context?  But, on the other hand, why wouldn&#8217;t it?</p>
<p>With Objective-C, any object can be taught how to draw itself.  Or how to serialise itself.  Or any other bit of functionality that a particular library wants to add.</p>
<p>It&#8217;s a bit of a disconnect at first, but once you know it&#8217;s happening it makes perfect sense, and the idea of extending basic types with your own categories seems perfectly reasonable.  Need to add a way to hex-encode the binary data in an NSData object?  Add it right to the NSData object using a category.  This makes it easier to find than the equivalent in other languages, which is typically to add some utility functions somewhere.</p>
<p>One tip:  If you&#8217;re adding categories in a static library, you will need to specify the &#8220;-all_load&#8221; flag to the linker.  If you don&#8217;t do this, the categories won&#8217;t be visible to the calling application and things won&#8217;t go well for you.  Normally the linker will discard things that it thinks aren&#8217;t being used, and it seems to get this wrong about categories, but -all_load forces the linker to keep the category methods.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stevex.net/2011/11/objective-c-categories/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Combining Videos in QuickTime on the Mac</title>
		<link>http://blog.stevex.net/2011/11/combining-videos-in-quicktime-on-the-mac/</link>
		<comments>http://blog.stevex.net/2011/11/combining-videos-in-quicktime-on-the-mac/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 14:07:22 +0000</pubDate>
		<dc:creator>stevex</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[video quicktime mac]]></category>

		<guid isPermaLink="false">http://blog.stevex.net/?p=1886</guid>
		<description><![CDATA[A quick QuickTime tip I just discovered.]]></description>
			<content:encoded><![CDATA[<p>A quick QuickTime tip I just discovered.</p>
<p><iframe width="560" height="315" src="http://www.youtube.com/embed/MMeSbEwmZEU" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stevex.net/2011/11/combining-videos-in-quicktime-on-the-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blogging from Siri</title>
		<link>http://blog.stevex.net/2011/11/blogging-from-siri/</link>
		<comments>http://blog.stevex.net/2011/11/blogging-from-siri/#comments</comments>
		<pubDate>Sat, 19 Nov 2011 18:49:28 +0000</pubDate>
		<dc:creator>stevex</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.stevex.net/2011/11/blogging-from-siri/</guid>
		<description><![CDATA[I&#8217;m sitting in the car at the Canada/US border, blogging into my phone, using Siri. There&#8217;s a 30 to 60 minute delay in crossing the border, so I have some time to play. So far I&#8217;ve dictated this entire post to Siri, without having to correct anything. Cool.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m sitting in the car at the Canada/US border, blogging into my phone, using Siri.</p>
<p>There&#8217;s a 30 to 60 minute delay in crossing the border, so I have some time to play.</p>
<p>So far I&#8217;ve dictated this entire post to Siri, without having to correct anything. </p>
<p>Cool.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stevex.net/2011/11/blogging-from-siri/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

