<?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>// do something here</title>
	<atom:link href="http://www.dosomethinghere.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dosomethinghere.com</link>
	<description>Turning impossibilities into 1s and 0s professionally since 0x07C1</description>
	<lastBuildDate>Wed, 22 May 2013 01:21:50 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>UIImage categories (part 2 of 4)</title>
		<link>http://www.dosomethinghere.com/2013/05/21/uiimage-categories-part-2-of-4/</link>
		<comments>http://www.dosomethinghere.com/2013/05/21/uiimage-categories-part-2-of-4/#comments</comments>
		<pubDate>Wed, 22 May 2013 01:21:50 +0000</pubDate>
		<dc:creator>BP</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.dosomethinghere.com/?p=1190</guid>
		<description><![CDATA[Here is the second category, where I take the UIImage with the clear background and crop it down. The algorithm is a bit brute force, but it seems to work fine. - &#40;UIImage *&#41;imageByTrimmingTransparentPixels &#123; int rows = self.size.height; int cols = self.size.width; int bytesPerRow = cols*sizeof&#40;uint8_t&#41;; &#160; if &#40; rows &#60; 2 &#124;&#124; cols [...]]]></description>
				<content:encoded><![CDATA[<p>Here is the second category, where I take the UIImage with the clear background and crop it down. The algorithm is a bit brute force, but it seems to work fine.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>UIImage <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>imageByTrimmingTransparentPixels
<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">int</span> rows <span style="color: #002200;">=</span> self.size.height;
	<span style="color: #a61390;">int</span> cols <span style="color: #002200;">=</span> self.size.width;
	<span style="color: #a61390;">int</span> bytesPerRow <span style="color: #002200;">=</span> cols<span style="color: #002200;">*</span><span style="color: #a61390;">sizeof</span><span style="color: #002200;">&#40;</span>uint8_t<span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> rows &lt; <span style="color: #2400d9;">2</span> || cols &lt; <span style="color: #2400d9;">2</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		<span style="color: #a61390;">return</span> self;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #11740a; font-style: italic;">//allocate array to hold alpha channel</span>
	uint8_t <span style="color: #002200;">*</span>bitmapData <span style="color: #002200;">=</span> <span style="color: #a61390;">calloc</span><span style="color: #002200;">&#40;</span>rows<span style="color: #002200;">*</span>cols, <span style="color: #a61390;">sizeof</span><span style="color: #002200;">&#40;</span>uint8_t<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">//create alpha-only bitmap context</span>
	CGContextRef contextRef <span style="color: #002200;">=</span> CGBitmapContextCreate<span style="color: #002200;">&#40;</span>bitmapData, cols, rows, <span style="color: #2400d9;">8</span>, bytesPerRow, <span style="color: #a61390;">NULL</span>, kCGImageAlphaOnly<span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">//draw our image on that context</span>
	CGImageRef cgImage <span style="color: #002200;">=</span> self.CGImage;
	CGRect rect <span style="color: #002200;">=</span> CGRectMake<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0</span>, cols, rows<span style="color: #002200;">&#41;</span>;
	CGContextDrawImage<span style="color: #002200;">&#40;</span>contextRef, rect, cgImage<span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">//summ all non-transparent pixels in every row and every column</span>
	uint16_t <span style="color: #002200;">*</span>rowSum <span style="color: #002200;">=</span> <span style="color: #a61390;">calloc</span><span style="color: #002200;">&#40;</span>rows, <span style="color: #a61390;">sizeof</span><span style="color: #002200;">&#40;</span>uint16_t<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;
	uint16_t <span style="color: #002200;">*</span>colSum <span style="color: #002200;">=</span> <span style="color: #a61390;">calloc</span><span style="color: #002200;">&#40;</span>cols, <span style="color: #a61390;">sizeof</span><span style="color: #002200;">&#40;</span>uint16_t<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">//enumerate through all pixels</span>
	<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span> <span style="color: #a61390;">int</span> row <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>; row &lt; rows; row<span style="color: #002200;">++</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span> <span style="color: #a61390;">int</span> col <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>; col &lt; cols; col<span style="color: #002200;">++</span><span style="color: #002200;">&#41;</span>
		<span style="color: #002200;">&#123;</span>
			<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> bitmapData<span style="color: #002200;">&#91;</span>row<span style="color: #002200;">*</span>bytesPerRow <span style="color: #002200;">+</span> col<span style="color: #002200;">&#93;</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span> <span style="color: #11740a; font-style: italic;">//found non-transparent pixel</span>
				rowSum<span style="color: #002200;">&#91;</span>row<span style="color: #002200;">&#93;</span><span style="color: #002200;">++</span>;
				colSum<span style="color: #002200;">&#91;</span>col<span style="color: #002200;">&#93;</span><span style="color: #002200;">++</span>;
			<span style="color: #002200;">&#125;</span>
		<span style="color: #002200;">&#125;</span>
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #11740a; font-style: italic;">//initialize crop insets and enumerate cols/rows arrays until we find non-empty columns or row</span>
	UIEdgeInsets crop <span style="color: #002200;">=</span> UIEdgeInsetsMake<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span> <span style="color: #a61390;">int</span> i <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>; i&lt;rows; i<span style="color: #002200;">++</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span> 		<span style="color: #11740a; font-style: italic;">//top</span>
		<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> rowSum<span style="color: #002200;">&#91;</span>i<span style="color: #002200;">&#93;</span> &gt; <span style="color: #2400d9;">0</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
			crop.top <span style="color: #002200;">=</span> i; <span style="color: #a61390;">break</span>;
		<span style="color: #002200;">&#125;</span>
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span> <span style="color: #a61390;">int</span> i <span style="color: #002200;">=</span> rows; i &gt;<span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>; i<span style="color: #002200;">--</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>		<span style="color: #11740a; font-style: italic;">//bottom</span>
		<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> rowSum<span style="color: #002200;">&#91;</span>i<span style="color: #002200;">&#93;</span> &gt; <span style="color: #2400d9;">0</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
			crop.bottom <span style="color: #002200;">=</span> MAX<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, rows<span style="color: #002200;">-</span>i<span style="color: #002200;">-</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span>; <span style="color: #a61390;">break</span>;
		<span style="color: #002200;">&#125;</span>
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span> <span style="color: #a61390;">int</span> i <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>; i&lt;cols; i<span style="color: #002200;">++</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>		<span style="color: #11740a; font-style: italic;">//left</span>
		<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> colSum<span style="color: #002200;">&#91;</span>i<span style="color: #002200;">&#93;</span> &gt; <span style="color: #2400d9;">0</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
			crop.left <span style="color: #002200;">=</span> i; <span style="color: #a61390;">break</span>;
		<span style="color: #002200;">&#125;</span>
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span> <span style="color: #a61390;">int</span> i <span style="color: #002200;">=</span> cols; i &gt;<span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>; i<span style="color: #002200;">--</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>		<span style="color: #11740a; font-style: italic;">//right</span>
		<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> colSum<span style="color: #002200;">&#91;</span>i<span style="color: #002200;">&#93;</span> &gt; <span style="color: #2400d9;">0</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
			crop.right <span style="color: #002200;">=</span> MAX<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, cols<span style="color: #002200;">-</span>i<span style="color: #002200;">-</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span>; <span style="color: #a61390;">break</span>;
		<span style="color: #002200;">&#125;</span>
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #a61390;">free</span><span style="color: #002200;">&#40;</span>bitmapData<span style="color: #002200;">&#41;</span>;
	<span style="color: #a61390;">free</span><span style="color: #002200;">&#40;</span>colSum<span style="color: #002200;">&#41;</span>;
	<span style="color: #a61390;">free</span><span style="color: #002200;">&#40;</span>rowSum<span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> crop.top <span style="color: #002200;">==</span> <span style="color: #2400d9;">0</span> <span style="color: #002200;">&amp;&amp;</span> crop.bottom <span style="color: #002200;">==</span> <span style="color: #2400d9;">0</span> <span style="color: #002200;">&amp;&amp;</span> crop.left <span style="color: #002200;">==</span> <span style="color: #2400d9;">0</span> <span style="color: #002200;">&amp;&amp;</span> crop.right <span style="color: #002200;">==</span> <span style="color: #2400d9;">0</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		<span style="color: #11740a; font-style: italic;">//no cropping needed</span>
		<span style="color: #a61390;">return</span> self;
	<span style="color: #002200;">&#125;</span>
	<span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span>
		<span style="color: #11740a; font-style: italic;">//calculate new crop bounds</span>
		rect.origin.x <span style="color: #002200;">+=</span> crop.left;
		rect.origin.y <span style="color: #002200;">+=</span> crop.top;
		rect.size.width <span style="color: #002200;">-=</span> crop.left <span style="color: #002200;">+</span> crop.right;
		rect.size.height <span style="color: #002200;">-=</span> crop.top <span style="color: #002200;">+</span> crop.bottom;
&nbsp;
		<span style="color: #11740a; font-style: italic;">//crop it</span>
		CGImageRef newImage <span style="color: #002200;">=</span> CGImageCreateWithImageInRect<span style="color: #002200;">&#40;</span>cgImage, rect<span style="color: #002200;">&#41;</span>;
&nbsp;
		<span style="color: #11740a; font-style: italic;">//convert back to UIImage</span>
		<span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>UIImage imageWithCGImage<span style="color: #002200;">:</span>newImage<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>Again, I would attribute this code if I could, but one of my former co-workers found this for me on some pastebin. If anyone knows where this code originally came from, please let me know and I will make the necessary attribution.</p>
<p>BTW, Happy Birthday today to Mr. T. (Yes, May 21 is slim pickings for birthdays, deaths, events, and holidays.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dosomethinghere.com/2013/05/21/uiimage-categories-part-2-of-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UIImage categories (part 1 of 4)</title>
		<link>http://www.dosomethinghere.com/2013/05/15/uiimage-categories-part-1-of-4/</link>
		<comments>http://www.dosomethinghere.com/2013/05/15/uiimage-categories-part-1-of-4/#comments</comments>
		<pubDate>Thu, 16 May 2013 02:34:41 +0000</pubDate>
		<dc:creator>BP</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iPhone SDK]]></category>

		<guid isPermaLink="false">http://www.dosomethinghere.com/?p=1187</guid>
		<description><![CDATA[My current iOS app gets images that I need to process. Basically, in my app, I get a UIImage with a white background and a CGRect, and I need to make the background of the image clear, automatically crop the image, scale image into the given CGRect preserving the aspect ratio, and then pad the [...]]]></description>
				<content:encoded><![CDATA[<p>My current iOS app gets images that I need to process. Basically, in my app, I get a UIImage with a white background and a CGRect, and I need to make the background of the image clear, automatically crop the image, scale image into the given CGRect preserving the aspect ratio, and then pad the scaled CGRect so that it appears centered inside of the original CGRect.</p>
<p>So in order to do this, I went through and found some UIImage categories to perform these tasks. Here is the first category that makes the white background into a clear background:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>UIImage <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>makeWhiteBackgroundTransparent
<span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>UIImage replaceColor<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIColor colorWithRed<span style="color: #002200;">:</span><span style="color: #2400d9;">1.0</span> green<span style="color: #002200;">:</span><span style="color: #2400d9;">1.0</span> blue<span style="color: #002200;">:</span><span style="color: #2400d9;">1.0</span> alpha<span style="color: #002200;">:</span><span style="color: #2400d9;">1.0</span><span style="color: #002200;">&#93;</span> inImage<span style="color: #002200;">:</span>self withTolerance<span style="color: #002200;">:</span><span style="color: #2400d9;">0.0</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span>UIImage <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>replaceColor<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIColor <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>color inImage<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIImage <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>image withTolerance<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">float</span><span style="color: #002200;">&#41;</span>tolerance
<span style="color: #002200;">&#123;</span>
    CGImageRef imageRef <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>image CGImage<span style="color: #002200;">&#93;</span>;
&nbsp;
    NSUInteger width <span style="color: #002200;">=</span> CGImageGetWidth<span style="color: #002200;">&#40;</span>imageRef<span style="color: #002200;">&#41;</span>;
    NSUInteger height <span style="color: #002200;">=</span> CGImageGetHeight<span style="color: #002200;">&#40;</span>imageRef<span style="color: #002200;">&#41;</span>;
    CGColorSpaceRef colorSpace <span style="color: #002200;">=</span> CGColorSpaceCreateDeviceRGB<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
    NSUInteger bytesPerPixel <span style="color: #002200;">=</span> <span style="color: #2400d9;">4</span>;
    NSUInteger bytesPerRow <span style="color: #002200;">=</span> bytesPerPixel <span style="color: #002200;">*</span> width;
    NSUInteger bitsPerComponent <span style="color: #002200;">=</span> <span style="color: #2400d9;">8</span>;
    NSUInteger bitmapByteCount <span style="color: #002200;">=</span> bytesPerRow <span style="color: #002200;">*</span> height;
&nbsp;
    <span style="color: #a61390;">unsigned</span> <span style="color: #a61390;">char</span> <span style="color: #002200;">*</span>rawData <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">unsigned</span> <span style="color: #a61390;">char</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> <span style="color: #a61390;">calloc</span><span style="color: #002200;">&#40;</span>bitmapByteCount, <span style="color: #a61390;">sizeof</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">unsigned</span> <span style="color: #a61390;">char</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
    CGContextRef context <span style="color: #002200;">=</span> CGBitmapContextCreate<span style="color: #002200;">&#40;</span>rawData, width, height,
                                                 bitsPerComponent, bytesPerRow, colorSpace,
                                                 kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big<span style="color: #002200;">&#41;</span>;
    CGColorSpaceRelease<span style="color: #002200;">&#40;</span>colorSpace<span style="color: #002200;">&#41;</span>;
&nbsp;
    CGContextDrawImage<span style="color: #002200;">&#40;</span>context, CGRectMake<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0</span>, width, height<span style="color: #002200;">&#41;</span>, imageRef<span style="color: #002200;">&#41;</span>;
&nbsp;
    CGColorRef cgColor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>color CGColor<span style="color: #002200;">&#93;</span>;
    <span style="color: #a61390;">const</span> CGFloat <span style="color: #002200;">*</span>components <span style="color: #002200;">=</span> CGColorGetComponents<span style="color: #002200;">&#40;</span>cgColor<span style="color: #002200;">&#41;</span>;
    <span style="color: #a61390;">float</span> r <span style="color: #002200;">=</span> components<span style="color: #002200;">&#91;</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#93;</span>;
    <span style="color: #a61390;">float</span> g <span style="color: #002200;">=</span> components<span style="color: #002200;">&#91;</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#93;</span>;
    <span style="color: #a61390;">float</span> b <span style="color: #002200;">=</span> components<span style="color: #002200;">&#91;</span><span style="color: #2400d9;">2</span><span style="color: #002200;">&#93;</span>;
    <span style="color: #11740a; font-style: italic;">//float a = components[3]; // not needed</span>
&nbsp;
    r <span style="color: #002200;">=</span> r <span style="color: #002200;">*</span> <span style="color: #2400d9;">255.0</span>;
    g <span style="color: #002200;">=</span> g <span style="color: #002200;">*</span> <span style="color: #2400d9;">255.0</span>;
    b <span style="color: #002200;">=</span> b <span style="color: #002200;">*</span> <span style="color: #2400d9;">255.0</span>;
&nbsp;
    <span style="color: #a61390;">const</span> <span style="color: #a61390;">float</span> redRange<span style="color: #002200;">&#91;</span><span style="color: #2400d9;">2</span><span style="color: #002200;">&#93;</span> <span style="color: #002200;">=</span> <span style="color: #002200;">&#123;</span>
        MAX<span style="color: #002200;">&#40;</span>r <span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>tolerance <span style="color: #002200;">/</span> <span style="color: #2400d9;">2.0</span><span style="color: #002200;">&#41;</span>, <span style="color: #2400d9;">0.0</span><span style="color: #002200;">&#41;</span>,
        MIN<span style="color: #002200;">&#40;</span>r <span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span>tolerance <span style="color: #002200;">/</span> <span style="color: #2400d9;">2.0</span><span style="color: #002200;">&#41;</span>, <span style="color: #2400d9;">255.0</span><span style="color: #002200;">&#41;</span>
    <span style="color: #002200;">&#125;</span>;
&nbsp;
    <span style="color: #a61390;">const</span> <span style="color: #a61390;">float</span> greenRange<span style="color: #002200;">&#91;</span><span style="color: #2400d9;">2</span><span style="color: #002200;">&#93;</span> <span style="color: #002200;">=</span> <span style="color: #002200;">&#123;</span>
        MAX<span style="color: #002200;">&#40;</span>g <span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>tolerance <span style="color: #002200;">/</span> <span style="color: #2400d9;">2.0</span><span style="color: #002200;">&#41;</span>, <span style="color: #2400d9;">0.0</span><span style="color: #002200;">&#41;</span>,
        MIN<span style="color: #002200;">&#40;</span>g <span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span>tolerance <span style="color: #002200;">/</span> <span style="color: #2400d9;">2.0</span><span style="color: #002200;">&#41;</span>, <span style="color: #2400d9;">255.0</span><span style="color: #002200;">&#41;</span>
    <span style="color: #002200;">&#125;</span>;
&nbsp;
    <span style="color: #a61390;">const</span> <span style="color: #a61390;">float</span> blueRange<span style="color: #002200;">&#91;</span><span style="color: #2400d9;">2</span><span style="color: #002200;">&#93;</span> <span style="color: #002200;">=</span> <span style="color: #002200;">&#123;</span>
        MAX<span style="color: #002200;">&#40;</span>b <span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>tolerance <span style="color: #002200;">/</span> <span style="color: #2400d9;">2.0</span><span style="color: #002200;">&#41;</span>, <span style="color: #2400d9;">0.0</span><span style="color: #002200;">&#41;</span>,
        MIN<span style="color: #002200;">&#40;</span>b <span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span>tolerance <span style="color: #002200;">/</span> <span style="color: #2400d9;">2.0</span><span style="color: #002200;">&#41;</span>, <span style="color: #2400d9;">255.0</span><span style="color: #002200;">&#41;</span>
    <span style="color: #002200;">&#125;</span>;
&nbsp;
    <span style="color: #a61390;">int</span> byteIndex <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
&nbsp;
    <span style="color: #a61390;">while</span> <span style="color: #002200;">&#40;</span>byteIndex &lt; bitmapByteCount<span style="color: #002200;">&#41;</span>
    <span style="color: #002200;">&#123;</span>
        <span style="color: #a61390;">unsigned</span> <span style="color: #a61390;">char</span> red   <span style="color: #002200;">=</span> rawData<span style="color: #002200;">&#91;</span>byteIndex<span style="color: #002200;">&#93;</span>;
        <span style="color: #a61390;">unsigned</span> <span style="color: #a61390;">char</span> green <span style="color: #002200;">=</span> rawData<span style="color: #002200;">&#91;</span>byteIndex <span style="color: #002200;">+</span> <span style="color: #2400d9;">1</span><span style="color: #002200;">&#93;</span>;
        <span style="color: #a61390;">unsigned</span> <span style="color: #a61390;">char</span> blue  <span style="color: #002200;">=</span> rawData<span style="color: #002200;">&#91;</span>byteIndex <span style="color: #002200;">+</span> <span style="color: #2400d9;">2</span><span style="color: #002200;">&#93;</span>;
&nbsp;
        <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span>red &gt;<span style="color: #002200;">=</span> redRange<span style="color: #002200;">&#91;</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&amp;&amp;</span> <span style="color: #002200;">&#40;</span>red &lt;<span style="color: #002200;">=</span> redRange<span style="color: #002200;">&#91;</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&amp;&amp;</span>
            <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span>green &gt;<span style="color: #002200;">=</span> greenRange<span style="color: #002200;">&#91;</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&amp;&amp;</span> <span style="color: #002200;">&#40;</span>green &lt;<span style="color: #002200;">=</span> greenRange<span style="color: #002200;">&#91;</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&amp;&amp;</span>
            <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span>blue &gt;<span style="color: #002200;">=</span> blueRange<span style="color: #002200;">&#91;</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&amp;&amp;</span> <span style="color: #002200;">&#40;</span>blue &lt;<span style="color: #002200;">=</span> blueRange<span style="color: #002200;">&#91;</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>
        <span style="color: #002200;">&#123;</span>
            <span style="color: #11740a; font-style: italic;">// make the pixel transparent</span>
            <span style="color: #11740a; font-style: italic;">//</span>
            rawData<span style="color: #002200;">&#91;</span>byteIndex<span style="color: #002200;">&#93;</span> <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
            rawData<span style="color: #002200;">&#91;</span>byteIndex <span style="color: #002200;">+</span> <span style="color: #2400d9;">1</span><span style="color: #002200;">&#93;</span> <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
            rawData<span style="color: #002200;">&#91;</span>byteIndex <span style="color: #002200;">+</span> <span style="color: #2400d9;">2</span><span style="color: #002200;">&#93;</span> <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
            rawData<span style="color: #002200;">&#91;</span>byteIndex <span style="color: #002200;">+</span> <span style="color: #2400d9;">3</span><span style="color: #002200;">&#93;</span> <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
        <span style="color: #002200;">&#125;</span>
&nbsp;
        byteIndex <span style="color: #002200;">+=</span> <span style="color: #2400d9;">4</span>;
    <span style="color: #002200;">&#125;</span>
&nbsp;
    CGImageRef imgRef <span style="color: #002200;">=</span> CGBitmapContextCreateImage<span style="color: #002200;">&#40;</span>context<span style="color: #002200;">&#41;</span>;
    UIImage <span style="color: #002200;">*</span>result <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIImage imageWithCGImage<span style="color: #002200;">:</span>imgRef<span style="color: #002200;">&#93;</span>;
    CGImageRelease<span style="color: #002200;">&#40;</span>imgRef<span style="color: #002200;">&#41;</span>;
&nbsp;
    CGContextRelease<span style="color: #002200;">&#40;</span>context<span style="color: #002200;">&#41;</span>;
    <span style="color: #a61390;">free</span><span style="color: #002200;">&#40;</span>rawData<span style="color: #002200;">&#41;</span>;
&nbsp;
    <span style="color: #a61390;">return</span> result;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>I would attribute this code, but I can&#8217;t find where I found this particular replaceColor method. If anyone knows where this code originally came from, please let me know and I will make the necessary attribution.</p>
<p>BTW, Happy Anniversary to McDonalds, who opened their first restaurant in San Bernardino, California on this date back in 1940.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dosomethinghere.com/2013/05/15/uiimage-categories-part-1-of-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dell Windows XP reinstall cannot find new SATA hard drive</title>
		<link>http://www.dosomethinghere.com/2013/05/08/dell-windows-xp-reinstall-cannot-find-new-sata-hard-drive/</link>
		<comments>http://www.dosomethinghere.com/2013/05/08/dell-windows-xp-reinstall-cannot-find-new-sata-hard-drive/#comments</comments>
		<pubDate>Thu, 09 May 2013 03:12:40 +0000</pubDate>
		<dc:creator>BP</dc:creator>
				<category><![CDATA[Hardware adventures]]></category>
		<category><![CDATA[Hardware]]></category>

		<guid isPermaLink="false">http://www.dosomethinghere.com/?p=1185</guid>
		<description><![CDATA[I recently have been trying to resurrect a Dell desktop computer with a bad hard drive, but after putting a new SATA hard drive in it, the Windows XP installer has not been able to find the hard drive. As it turns out, I had to go into the BIOS settings on the computer, and [...]]]></description>
				<content:encoded><![CDATA[<p>I recently have been trying to resurrect a Dell desktop computer with a bad hard drive, but after putting a new SATA hard drive in it, the Windows XP installer has not been able to find the hard drive. As it turns out, I had to go into the BIOS settings on the computer, and change the hard drive setting from &#8220;Autodetect RAID / ACHI&#8221; to &#8220;Autodetect RAID / ATA&#8221;, after which I was able to make the installer happy. Huzzah!</p>
<p>BTW, Happy Birthday to <a href="http://jbonamassa.com/" target="_blank">Joe Bonamassa</a>, one of my favorite all-time artists. I can&#8217;t wait to see Joe later this year when he comes back and plays Ohio. (Hey Joe, Columbus is a better crowd than Cleveland. Just sayin&#8217;.)</p>
<p>And on a somber note, I learned this afternoon of the passing of <a href="http://www.imdb.com/name/nm0178137/" target="_blank">Jeanne Cooper</a>, the long time Mrs. Chancellor character on <a href="http://www.cbs.com/shows/the_young_and_the_restless/" target="_blank">The Young and The Restless</a>. I hope they do not try to put another actress in that character, Michael Learned did an OK job but it just won&#8217;t be the same without the original Mrs. C.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dosomethinghere.com/2013/05/08/dell-windows-xp-reinstall-cannot-find-new-sata-hard-drive/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What UIViewController class am I looking at right now?</title>
		<link>http://www.dosomethinghere.com/2013/04/18/what-uiviewcontroller-class-am-i-looking-at-right-now/</link>
		<comments>http://www.dosomethinghere.com/2013/04/18/what-uiviewcontroller-class-am-i-looking-at-right-now/#comments</comments>
		<pubDate>Thu, 18 Apr 2013 17:20:09 +0000</pubDate>
		<dc:creator>BP</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iPhone SDK]]></category>

		<guid isPermaLink="false">http://www.dosomethinghere.com/?p=1168</guid>
		<description><![CDATA[When you are looking at unfamiliar iOS Objective-C code (either someone else&#8217;s or your own), it can be tricky to figure out where code can be hiding out within a project. Well no more. I found this interesting bit of method swizzling from Michael Armstrong that will show you which UIViewController subclass in on the [...]]]></description>
				<content:encoded><![CDATA[<p>When you are looking at unfamiliar iOS Objective-C code (either someone else&#8217;s or your own), it can be tricky to figure out where code can be hiding out within a project.</p>
<p>Well no more. I found this interesting bit of method swizzling from <a href="https://github.com/michaelarmstrong" target="_blank">Michael Armstrong</a> that will show you which UIViewController subclass in on the screen at any time.</p>
<p><a href="https://github.com/michaelarmstrong/MADebugTools" target="_blank">MADebugTools</a></p>
<p>I went into this code and added a #define that I am setting in my .pch file, so that I can turn off the view controller labels if I do not need to see them.</p>
<p>As an iOS aside, if you are an iOS developer, I would recommend following Romain Briche either on <a href="https://twitter.com/romainbriche" target="_blank">Twitter</a> or on his <a href="http://romainbriche.com/" target="_blank">web site</a>. I have found quite a few useful controls, code samples, and other hints and tutorials as a result of Romain&#8217;s postings.</p>
<p>BTW, Happy Birthday to <a href="http://www.melodythomasscott.com" target="_blank">Melody Thomas Scott</a>, who I thought was fantastic in <a href="http://www.imdb.com/title/tt0075809/" target="_blank">The Car</a>, one of my all time favorite movies. (Oh, and she is on <a href="http://www.cbs.com/shows/the_young_and_the_restless/" target="_blank">The Young and The Restless</a>, too.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dosomethinghere.com/2013/04/18/what-uiviewcontroller-class-am-i-looking-at-right-now/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Logging an iOS class instance</title>
		<link>http://www.dosomethinghere.com/2013/04/15/logging-an-ios-class-instance/</link>
		<comments>http://www.dosomethinghere.com/2013/04/15/logging-an-ios-class-instance/#comments</comments>
		<pubDate>Mon, 15 Apr 2013 22:20:42 +0000</pubDate>
		<dc:creator>BP</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iPhone SDK]]></category>

		<guid isPermaLink="false">http://www.dosomethinghere.com/?p=1165</guid>
		<description><![CDATA[I found this interesting category of NSObject from Simon Strandgaard that walks through your instance&#8217;s class variables and builds up a description string, which you can then output to the console. Here is the link to the category on Github: https://github.com/neoneye/autodescribe BTW, Happy Birthday to Lois Chiles, the who played Dr. Goodhead in the James [...]]]></description>
				<content:encoded><![CDATA[<p>I found this interesting category of NSObject from <a href="https://github.com/neoneye" target="_blank">Simon Strandgaard</a> that walks through your instance&#8217;s class variables and builds up a description string, which you can then output to the console. Here is the link to the category on Github:</p>
<p><a href="https://github.com/neoneye/autodescribe" target="_blank">https://github.com/neoneye/autodescribe</a></p>
<p>BTW, Happy Birthday to <a href="http://en.wikipedia.org/wiki/Lois_Chiles" target="_blank">Lois Chiles</a>, the who played Dr. Goodhead in the James Bond movie <a href="http://www.imdb.com/title/tt0079574/" target="_blank">Moonraker</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dosomethinghere.com/2013/04/15/logging-an-ios-class-instance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Xcode 4.6 Organizer crash on update</title>
		<link>http://www.dosomethinghere.com/2013/03/27/xcode-4-6-organizer-crash-on-update/</link>
		<comments>http://www.dosomethinghere.com/2013/03/27/xcode-4-6-organizer-crash-on-update/#comments</comments>
		<pubDate>Thu, 28 Mar 2013 03:15:25 +0000</pubDate>
		<dc:creator>BP</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iPhone SDK]]></category>

		<guid isPermaLink="false">http://www.dosomethinghere.com/?p=1162</guid>
		<description><![CDATA[Well I had a nice little issue with Xcode. Whenever I would try to do something in Organizer that had to sign into my Apple developer account (refresh provisioning profiles, add a device to a provisioning profile, etc.), it would ask for my credentials, chug for a moment, and then slip out the back door [...]]]></description>
				<content:encoded><![CDATA[<p>Well I had a nice little issue with Xcode. Whenever I would try to do something in Organizer that had to sign into my Apple developer account (refresh provisioning profiles, add a device to a provisioning profile, etc.), it would ask for my credentials, chug for a moment, and then slip out the back door like it was late for a date with a supermodel.</p>
<p>Luckily, today I got frustrated with this issue and did some digging. I found a post on Apple&#8217;s forums about getting rid of some Library files created and used by Xcode, and after I removed the two files in question, lo and behold it started to be non-crashy again. Bonus.</p>
<p>The files were in the folder &#8220;~/Library/Developer/Xcode/&#8221; and begin with &#8220;connect1.apple.com&#8221;. Apple&#8217;s post says to move the files, but I just blew them away and it seemed to work fine. Here is the post on the Apple web site: (you may need to log in with your Apple developer account to see this posting)</p>
<p><a href="https://devforums.apple.com/message/796388#796388" target="_blank">Xcode 4.6.1 crashing while interacting with the Developer Portal </a></p>
<p>BTW, Happy Birthday to <a href="http://www.routzy.com/" target="_blank">Routzy</a>! We had our one year birthday party for Routzy tonight at <a href="http://www.vitoswinebar.com/" target="_blank">Vito&#8217;s Wine Bar</a> in Delaware, Ohio. Thanks to all who turned out, and wait until you see what we have in store for <a href="https://itunes.apple.com/us/app/routzy-mobile-crm-sales-app/id487646442?mt=8&#038;ign-mpt=uo%3D4" target="_blank">Routzy</a> in year 2.</p>
<p>Post script: Happy Belated 40th Birthday to The Young and The Restless.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dosomethinghere.com/2013/03/27/xcode-4-6-organizer-crash-on-update/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>iOS NSRegularExpression to detect UUID</title>
		<link>http://www.dosomethinghere.com/2013/03/14/ios-nsregularexpression-to-detect-uuid/</link>
		<comments>http://www.dosomethinghere.com/2013/03/14/ios-nsregularexpression-to-detect-uuid/#comments</comments>
		<pubDate>Thu, 14 Mar 2013 18:22:40 +0000</pubDate>
		<dc:creator>BP</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iPhone SDK]]></category>

		<guid isPermaLink="false">http://www.dosomethinghere.com/?p=1158</guid>
		<description><![CDATA[In keeping with my attempt to use more regular expressions in .NET, I figured it would be a good exercise to try and use NSRegularExpression to do some checking in my iOS app. I have a situation where an array of strings come in, and I need to know which of them are UUIDs and [...]]]></description>
				<content:encoded><![CDATA[<p>In keeping with my attempt to use more regular expressions in .NET, I figured it would be a good exercise to try and use <a href="https://developer.apple.com/library/mac/#documentation/Foundation/Reference/NSRegularExpression_Class/Reference/Reference.html" target="_blank">NSRegularExpression</a> to do some checking in my iOS app.</p>
<p>I have a situation where an array of strings come in, and I need to know which of them are UUIDs and which are not. Here is the code that I wrote to accomplish the UUID checking, it is implemented as a category of NSString:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#define UUID_PATTERN    @&quot;^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$&quot;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>isUUID
<span style="color: #002200;">&#123;</span>
    NSRegularExpression <span style="color: #002200;">*</span>regex;
    regex <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>NSRegularExpression regularExpressionWithPattern<span style="color: #002200;">:</span>UUID_PATTERN
                                                      options<span style="color: #002200;">:</span>NSRegularExpressionCaseInsensitive
                                                        error<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
    <span style="color: #a61390;">int</span> matches <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>regex numberOfMatchesInString<span style="color: #002200;">:</span>self options<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span>
                                           range<span style="color: #002200;">:</span>NSMakeRange<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, <span style="color: #002200;">&#91;</span>self length<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
    <span style="color: #a61390;">return</span> <span style="color: #002200;">&#40;</span>matches <span style="color: #002200;">==</span> <span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>To use this NSString category, you would just do something like this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Is %@ a UUID? %@&quot;</span>, theTestString, <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>theTestString isUUID<span style="color: #002200;">&#93;</span> ? <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;YES&quot;</span> <span style="color: #002200;">:</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;NO&quot;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;</pre></td></tr></table></div>

<p>BTW, as far as I am concerned, Google laid a couple of eggs the last two days. Firstly, yesterday (Wednesday, March 13) I tried for almost an hour to get Google I/O tickets, to no avail. I was hoping to attend as my trip to I/O last year was interrupted by my father passing away. Then, this morning, news breaks that Google is killing off Google Reader. My opinion of Google has gone down a couple of notches.</p>
<p>Double Bonus BTW: Happy Pi Day everyone! See you at <a href="http://www.stirtrek.com" target="_blank">Stir Trek</a>!!! (Yes, I got tickets for that one. Whew&#8230;)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dosomethinghere.com/2013/03/14/ios-nsregularexpression-to-detect-uuid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mamas, don&#8217;t let your babies grow up to put important code in the dealloc method</title>
		<link>http://www.dosomethinghere.com/2013/03/05/mamas-dont-let-your-babies-grow-up-to-put-important-code-in-the-dealloc-metho/</link>
		<comments>http://www.dosomethinghere.com/2013/03/05/mamas-dont-let-your-babies-grow-up-to-put-important-code-in-the-dealloc-metho/#comments</comments>
		<pubDate>Tue, 05 Mar 2013 19:58:58 +0000</pubDate>
		<dc:creator>BP</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.dosomethinghere.com/?p=1151</guid>
		<description><![CDATA[Here is something you may not have noticed (yet). If you use the ZipArchive code to create zip files in your iOS app, and you convert your app code to ARC, your zip files might not be created correctly. The problem exists here in the ZipArchive.mm file: -&#40;void&#41; dealloc &#123; &#91;self CloseZipFile2&#93;; &#91;super dealloc&#93;; &#125; [...]]]></description>
				<content:encoded><![CDATA[<p>Here is something you may not have noticed (yet). If you use the <a href="https://code.google.com/p/ziparchive/" target="_blank">ZipArchive code</a> to create zip files in your iOS app, and you convert your app code to ARC, your zip files might not be created correctly. The problem exists here in the ZipArchive.mm file:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> dealloc
<span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span>self CloseZipFile2<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>super dealloc<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>If you use the CreateZipFile2 method to create your zip file, previously you would call the release method on your ZipArchive object, and the memory would be flushed away. Unbeknownst to you (but beknownst to the ZipArchive devs), your zip file was A-OK because of the CloseZipFile2 method call in the dealloc method.</p>
<p>But ARC conversion removes the release messages! Bugger!!! Just manually put in a call to CloseZipFile2 everywhere that you use the CreateZipFile2 method.</p>
<p>BTW, Happy Birthday to <a href="http://en.wikipedia.org/wiki/Kent_Tekulve" target="_blank">Kent Tekulve</a>, former Pirates great and commissioner of the <a href="http://piratesfantasycamp.blogspot.com/" target="_blank">Pittsburgh Pirates Fantasy Camp</a>. Unfortunately Teke could not make it to camp due to illness this year, we missed you Teke and hope you are feeling better.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dosomethinghere.com/2013/03/05/mamas-dont-let-your-babies-grow-up-to-put-important-code-in-the-dealloc-metho/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Writing your first Android App (GDG Columbus meeting, February 21, 2013)</title>
		<link>http://www.dosomethinghere.com/2013/02/22/writing-your-first-android-app-gdg-columbus-meeting-february-21-2013/</link>
		<comments>http://www.dosomethinghere.com/2013/02/22/writing-your-first-android-app-gdg-columbus-meeting-february-21-2013/#comments</comments>
		<pubDate>Fri, 22 Feb 2013 14:33:06 +0000</pubDate>
		<dc:creator>BP</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.dosomethinghere.com/?p=1148</guid>
		<description><![CDATA[Last night, I attended the Google Developers Group Columbus meeting &#8220;Writing your first Android App presentation&#8221; at the Blue Diesel offices here in town. Special thanks to Casey Borders, the main presenter who kept us moving through the code heavy presentation. I am still a novice when it comes to Android development, so I did [...]]]></description>
				<content:encoded><![CDATA[<p>Last night, I attended the Google Developers Group Columbus meeting &#8220;Writing your first Android App presentation&#8221; at the Blue Diesel offices here in town. Special thanks to Casey Borders, the main presenter who kept us moving through the code heavy presentation. I am still a novice when it comes to Android development, so I did learn quite a bit at the meeting.</p>
<p>BTW, happy birthday to Jeri Ryan, who capably portrayed Seven of Nine in Star Trek Voyager.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dosomethinghere.com/2013/02/22/writing-your-first-android-app-gdg-columbus-meeting-february-21-2013/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing the SQLite error &#8220;The database disk image is malformed&#8221;</title>
		<link>http://www.dosomethinghere.com/2013/02/20/fixing-the-sqlite-error-the-database-disk-image-is-malformed/</link>
		<comments>http://www.dosomethinghere.com/2013/02/20/fixing-the-sqlite-error-the-database-disk-image-is-malformed/#comments</comments>
		<pubDate>Wed, 20 Feb 2013 16:59:28 +0000</pubDate>
		<dc:creator>BP</dc:creator>
				<category><![CDATA[SQLite]]></category>

		<guid isPermaLink="false">http://www.dosomethinghere.com/?p=1143</guid>
		<description><![CDATA[I suppose it was only a matter of time before someone&#8217;s database got corrupted. Of course, customers don&#8217;t want to hear that their issue is a once-in-a-year issue, they just want to get their data back. (Of course, they have used the app for a long time and not done any backups, but that topic [...]]]></description>
				<content:encoded><![CDATA[<p>I suppose it was only a matter of time before someone&#8217;s database got corrupted. Of course, customers don&#8217;t want to hear that their issue is a once-in-a-year issue, they just want to get their data back. (Of course, they have used the app for a long time and not done any backups, but that topic could fill an entire blog.)</p>
<p>Here are the steps I took to address this issue:</p>
<p>1. Use the sqlite3 app in the Mac OS X Terminal to create a .SQL export file</p>
<p>So I fired up the Terminal and changed to the directory where I had saved the bad database file, and entered the command:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="text" style="font-family:monospace;">sqlite3 DB.sqlite</pre></td></tr></table></div>

<p>This launches the sqlite> prompt, at which I entered the following commands:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="text" style="font-family:monospace;">.mode insert
.output dump_all.sql
.dump
.exit</pre></td></tr></table></div>

<p>At this point, you have the .SQL file in the same directory as the bad database file.</p>
<p>2. Remove transaction statements from the file</p>
<p>I received some errors in the next step, so I would recommend that you manually edit the .SQL file and remove any kind of transaction statements. In my example, there was a BEGIN TRANSACTION statement on the 2nd line of the file and a ROLLBACK statement on the last line. I removed both of these lines and re-saved the file.</p>
<p>3. Use the <a href="https://addons.mozilla.org/en-us/firefox/addon/sqlite-manager/" target="_blank">SQLite Manager extension</a> for Firefox to create a new database file and import the .SQL file</p>
<p>The last step is to launch your Firefox and open the SQLite Manager extension, create a brand new database, select Import from the Database menu, click Select File and find the .SQL file, make sure the BEGIN TRANSACTION/COMMIT check box is clear, and click OK.</p>
<p>At this point, I had a new SQLite file that did not give the malformed error message any more. As with any database file corruption issues, I probably got a bit lucky that the file was not too badly damaged, or damaged beyond repair.</p>
<p>Here was the blog post by Sergei Dorogin that I found that got me part way to the solution in my instance:</p>
<p><a href="http://techblog.dorogin.com/2011/05/sqliteexception-database-disk-image-is.html" target="_blank">SQLiteException &#8220;database disk image is malformed&#8221;</a></p>
<p>BTW, Happy Birthday to <a href="http://en.wikipedia.org/wiki/Roy_Face" target="_blank">Roy Face</a>, the former great Pittsburgh Pirates pitcher. He was one of the coaches at this past year&#8217;s Pirates Fantasy Camp, and seemed like a very nice person.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dosomethinghere.com/2013/02/20/fixing-the-sqlite-error-the-database-disk-image-is-malformed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
