<?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>farp.blog &#187; iPhone SDK</title>
	<atom:link href="http://fredandrandall.com/blog/tag/iphone-sdk/feed/" rel="self" type="application/rss+xml" />
	<link>http://fredandrandall.com/blog</link>
	<description>Bloggin&#039; about whatever</description>
	<lastBuildDate>Tue, 04 Nov 2014 07:15:30 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.0.38</generator>
	<item>
		<title>Afternoon Apps: Captionator</title>
		<link>http://fredandrandall.com/blog/2012/08/20/afternoon-apps-captionator/</link>
		<comments>http://fredandrandall.com/blog/2012/08/20/afternoon-apps-captionator/#comments</comments>
		<pubDate>Mon, 20 Aug 2012 04:47:19 +0000</pubDate>
		<dc:creator><![CDATA[Randall]]></dc:creator>
				<category><![CDATA[Afternoon Apps]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coregraphics]]></category>
		<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[quartzcore]]></category>

		<guid isPermaLink="false">http://fredandrandall.com/blog/?p=752</guid>
		<description><![CDATA[A couple weeks ago, a friend of mine showed me the app I&#8217;d Cap That. After making some hilarious pictures, and after a few drinks, I made the claim that I could probably clone the app in a couple of &#8230; <a href="http://fredandrandall.com/blog/2012/08/20/afternoon-apps-captionator/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://fredandrandall.com/blog/wp-content/uploads/2012/08/photo-3.jpg"><img class="alignleft size-medium wp-image-756" title="Captionator" src="http://fredandrandall.com/blog/wp-content/uploads/2012/08/photo-3-300x225.jpg" alt="" width="300" height="225" /></a>A couple weeks ago, a friend of mine showed me the app <a href="http://itunes.apple.com/us/app/id-cap-that/id510544616?mt=8">I&#8217;d Cap That</a>. After making some hilarious pictures, and after a few drinks, I made the claim that I could probably clone the app in a couple of hours.</p>
<p>So the other day, that&#8217;s what I tried to do. The app is very simple. It takes a randomly generated caption and burns it on to an image. You can pick an image from your camera or your library.</p>
<p>When I wrote the BD&#8217;s Mongolian BBQ app, I took stamps and burned them onto an image to create funny mustache pictures. The way I did that was to position UIImageViews inside of a UIView and then render the view to an image. That strategy works fine, but it also drops the image resolution down quite a bit. (It will be whatever the size of the view is)</p>
<p>So this time, I decided to render the text directly onto the image by hand. This involves getting a graphics context, drawing the image into it, then drawing the text into it, and finally getting the resulting UIImage from the graphics context.</p>
<p>My first approach was to use a UILabel to render the text onto the image. That would take care of all the font sizing issues and save some code. This worked great, until I had white text on a light image. There&#8217;s a couple ways to solve this problem like putting a stroke around the text or adding a shadow to the text. I&#8217;d Cap That uses a shadow. I decided to go for a more meme style look and stroke the text.</p>
<p>Unfortunately, UILabel doesn&#8217;t support adding a stroke around the text. So I looked for some classes online that might get the job done. I found a couple, but they didn&#8217;t work like I wanted. Luckily, CoreGraphics lets you draw stroked text, you just have to handle more by yourself.</p>
<pre class="brush: objc; title: ; notranslate">
-(UIImage*)getImage:(UIImage*)image withCaption:(NSString*)captionString
{
   UIGraphicsBeginImageContext([image size]);
   [image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];

   CGFloat captionFontSize = 300;
   CGSize captionSize = [captionString sizeWithFont:[UIFont boldSystemFontOfSize:captionFontSize]];

   while( captionSize.width &gt; image.size.width )
   {
      captionFontSize -= 5;
      captionSize = [captionString sizeWithFont:[UIFont boldSystemFontOfSize:captionFontSize]];
   }

   CGRect captionRect = CGRectMake((image.size.width - captionSize.width)/2.0, (image.size.height * .95)-captionSize.height, captionSize.width, captionSize.height);

   CGContextRef context = UIGraphicsGetCurrentContext();
   CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
   CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor);
   CGContextSetLineWidth(context, 3.0f);
   CGContextSetTextDrawingMode(context, kCGTextFillStroke);

   [captionString drawInRect:captionRect withFont:[UIFont boldSystemFontOfSize:captionFontSize]];

   UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext();

   UIGraphicsEndImageContext();
   return outputImage;
}
</pre>
<p>The problem with rendering the text yourself is that you need to size the font yourself. The way I&#8217;m doing it is picking a large font size (300 in this case) then measuring it and adjusting the font size until it fits on the image. There&#8217;s likely a better way, but this works and is fast enough.</p>
<p>I haven&#8217;t decided if I&#8217;m gonna release this app or not, like I did with my other <a title="Afternoon Apps: Descrumbled" href="http://fredandrandall.com/blog/2011/11/06/afternoon-apps-descrumbled/">Afternoon</a> <a title="Afternoon Apps 2: Scrumbled" href="http://fredandrandall.com/blog/2011/11/21/afternoon-apps-2-scrumbled/">Apps</a>. I have the <a href="https://github.com/blladnar/Captionator">source code up on GitHub</a> though, so feel free to take a look and use whatever you want from it.</p>
<p>There&#8217;s some issues with it. The camera view doesn&#8217;t work quite right. There aren&#8217;t any icons. One little feature in there is you can add to the list of captions. Of course the real secret sauce of I&#8217;d Cap That isn&#8217;t the app, it&#8217;s the hilarious captions.</p>
]]></content:encoded>
			<wfw:commentRss>http://fredandrandall.com/blog/2012/08/20/afternoon-apps-captionator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Afternoon Apps: Descrumbled</title>
		<link>http://fredandrandall.com/blog/2011/11/06/afternoon-apps-descrumbled/</link>
		<comments>http://fredandrandall.com/blog/2011/11/06/afternoon-apps-descrumbled/#comments</comments>
		<pubDate>Mon, 07 Nov 2011 02:39:00 +0000</pubDate>
		<dc:creator><![CDATA[Randall]]></dc:creator>
				<category><![CDATA[Afternoon Apps]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iPhone SDK]]></category>

		<guid isPermaLink="false">http://fredandrandall.com/blog/?p=650</guid>
		<description><![CDATA[At events like Startup Weekend, you try to build an idea in a weekend. I wanted to see if I could do something even faster. So I bring you Afternoon Apps, where I build an app in a single afternoon. &#8230; <a href="http://fredandrandall.com/blog/2011/11/06/afternoon-apps-descrumbled/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://fredandrandall.com/blog/wp-content/uploads/2011/11/DescrumbledLogo1.png"><img class="alignleft size-full wp-image-654" title="DescrumbledLogo" src="http://fredandrandall.com/blog/wp-content/uploads/2011/11/DescrumbledLogo1.png" alt="" width="198" height="60" /></a>At events like Startup Weekend, you try to build an idea in a weekend. I wanted to see if I could do something even faster. So I bring you <a href="http://fredandrandall.com/blog/category/afternoon-apps/">Afternoon Apps</a>, where I build an app in a single afternoon.</p>
<p><a href="http://descrumbled.com">Descrumbled</a> is an app for solving Boggle puzzles. Boggle is a word game where you have to find words hidden in a grid of letters. The app lets you enter a board and quickly generate all possible words that can be found in the puzzle. It uses the <a href="http://en.wikipedia.org/wiki/SOWPODS">SOWPODS</a> dictionary to see if a word is valid or not.</p>
<p>I was able to build the app in an afternoon because it is very simple. It lets you pick two board sizes, 4&#215;4 and 5&#215;5. Then you can enter the board, press solve, and seconds later you get a list of all the words. Pressing a word will give you the definition thanks to iOS 5&#8217;s dictionary integration.</p>
<p>The hard part was actually solving the puzzle. Generating all the possible words in the puzzle and checking them against a 230,000 word dictionary is no trivial task. I&#8217;m going to let you in on a little secret. I didn&#8217;t write the boggle solver in a single afternoon. I had written it before by working on it a few hours a day for 3 or so days. It was a programming challenge I found online and I tried to do it. It&#8217;s actually a lot of fun solving a problem like this. I get to think about tries and binary searches. Things I haven&#8217;t actually had to think much about since college. My first stab at it took about 3 minutes to solve a 4&#215;4 puzzle. Since most online Boggle rounds are 1 or 2 minutes, this obviously wasn&#8217;t acceptable. I improved my algorithm and now it takes ~1 second to solve a 5&#215;5 puzzle.</p>
<p>So what did I actually do in an afternoon? I built a UI around my boggle solver class. I had to get a C++ class working on the iPhone (which is actually really easy) and build a UI for entering the board. The squares on the board auto advance the cursor through a grid of UITextFields. It also makes sure the board is complete before it tries to solve. Then I had to make a way to clear the board and switch between a 4&#215;4 grid and a 5&#215;5 grid. The word list UI is just a very simple UITableView. When you press a row, it will open up the definition of the word in a UIReferenceLibraryViewController (new in iOS 5).</p>
<p>That&#8217;s it. The app is meant to be simple and easy to use. It really is a <a href="http://en.wikipedia.org/wiki/Minimum_viable_product">minimum viable product</a>. I did this as an exercise to see if I could build a simple app and submit it to the app store in an afternoon. I want to keep doing these Afternoon Apps every few weeks. I&#8217;d love to see if other people have done similar things and find out how your experience went.</p>
<p>The app should be live any day now. <a href="http://descrumbled.com">Check it out!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fredandrandall.com/blog/2011/11/06/afternoon-apps-descrumbled/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Making your iPhone app look great on an iPad</title>
		<link>http://fredandrandall.com/blog/2011/10/24/making-your-iphone-app-look-great-on-an-ipad/</link>
		<comments>http://fredandrandall.com/blog/2011/10/24/making-your-iphone-app-look-great-on-an-ipad/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 12:38:19 +0000</pubDate>
		<dc:creator><![CDATA[Randall]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[iPhone SDK]]></category>

		<guid isPermaLink="false">http://fredandrandall.com/blog/?p=638</guid>
		<description><![CDATA[Running an iPhone app on an iPad isn&#8217;t the best experience. It doesn&#8217;t use the iPad keyboard and everything looks very pixelated. Ideally, you would build an iPad version of your app, but that&#8217;s not always worthwhile. The iPad is &#8230; <a href="http://fredandrandall.com/blog/2011/10/24/making-your-iphone-app-look-great-on-an-ipad/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://fredandrandall.com/blog/wp-content/uploads/2011/10/photo.png"><img class="alignleft size-medium wp-image-641" title="photo" src="http://fredandrandall.com/blog/wp-content/uploads/2011/10/photo-225x300.png" alt="" width="225" height="300" /></a>Running an iPhone app on an iPad isn&#8217;t the best experience. It doesn&#8217;t use the iPad keyboard and everything looks very pixelated. Ideally, you would build an iPad version of your app, but that&#8217;s not always worthwhile. The iPad is a very different beast than the iPhone and it usually involves creating a completely unique experience for your app. So how can you make your iPhone app look better on an iPad?</p>
<p>Images. With the iPhone 4, Apple introduced an image naming schema that would allow you to load large images for the retina display and small ones for devices without it.</p>
<p>When the iPad launches an iPhone app, it launches it at the original iPhone resolution of 320&#215;480. When you press the 2x button on the iPad it will stretch it out to 640&#215;960 (the same resolution as the retina display).</p>
<p>This stretching, makes everything double in size and it all looks pixelated. So if you have an image that is 100 pixels wide, it will become 200 pixels wide and look like crap. But what happens if the image you provide is already 200 pixels wide?</p>
<p>It turns out that it looks pretty good. It shows up at the correct resolution with no pixelation.</p>
<p>The only problem with this is that if you give it a low res image, it will load it. Then it stretches and looks like crap. What you need to do is forget about the low res images and just include hi-res images.</p>
<p>&#8220;Won&#8217;t it look bad on the iPhone 3GS?&#8221; No. It&#8217;ll look fine. It&#8217;s scaling by half. Even the most rudimentary scaling algorithms look fine when it&#8217;s perfectly halved. You might lose a little bit of detail on some images, but it&#8217;s not much more detail than you&#8217;d lose using Photoshop to scale the images. Nobody will notice.</p>
<p>You can use the @2x naming convention if you want to, the images will all load just fine. There is a bug in Xcode 4&#8217;s interface builder that causes it to fail to load the images unless you put the @2x in the image name. This used to work in Xcode 3 before.</p>
<p>Including 2 images now is kind of silly. It makes the app larger (which can prevent you from downloading over 3G) and adds extra files that you need to manage. It&#8217;s easy to misname an image and end up with a pixelated piece of crap on your phone. The large images look just fine on the low res screens. I promise. It&#8217;s really too bad that iOS doesn&#8217;t render an iPhone app at the larger resolution on the iPad. It already knows how to draw the app at the double resolution for the retina display. Maybe with iOS 6.0.</p>
]]></content:encoded>
			<wfw:commentRss>http://fredandrandall.com/blog/2011/10/24/making-your-iphone-app-look-great-on-an-ipad/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Building a static library that works on the iPhone and the simulator</title>
		<link>http://fredandrandall.com/blog/2011/10/22/building-a-static-library-that-works-on-the-iphone-and-the-simulator/</link>
		<comments>http://fredandrandall.com/blog/2011/10/22/building-a-static-library-that-works-on-the-iphone-and-the-simulator/#comments</comments>
		<pubDate>Sat, 22 Oct 2011 15:03:15 +0000</pubDate>
		<dc:creator><![CDATA[Randall]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[objc]]></category>

		<guid isPermaLink="false">http://fredandrandall.com/blog/?p=629</guid>
		<description><![CDATA[Apple&#8217;s iPhone simulator runs really smooth and fast. This is because they aren&#8217;t emulating the ARM code on your Mac, they&#8217;re actually building x86 binaries that will run in the simulator. Because of this, code written for the iPhone needs &#8230; <a href="http://fredandrandall.com/blog/2011/10/22/building-a-static-library-that-works-on-the-iphone-and-the-simulator/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Apple&#8217;s iPhone simulator runs really smooth and fast. This is because they aren&#8217;t emulating the ARM code on your Mac, they&#8217;re actually building x86 binaries that will run in the simulator.</p>
<p>Because of this, code written for the iPhone needs to be compiled twice, once for the simulator and once for the device. This makes working with static libraries a bit of a pain, because you need two of them, one for each architecture.</p>
<p>Luckily, it&#8217;s possible to build a &#8220;universal&#8221; binary that will work with both architectures. Apple did this during their switch from PowerPC to Intel.<br />
<span id="more-629"></span></p>
<p>I found the directions in <a href="http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4">this StackOverflow post</a>.</p>
<p><a href="http://fredandrandall.com/blog/wp-content/uploads/2011/10/buildPhase.png"><img class="aligncenter size-full wp-image-633" title="buildPhase" src="http://fredandrandall.com/blog/wp-content/uploads/2011/10/buildPhase.png" alt="" width="877" height="443" /></a></p>
<ul>
<li>All you need to do is create a new static library target.</li>
<li>Add a &#8220;Run Script&#8221; build phase.</li>
<li>Copy and paste this script in.</li>
<li>Your build output should be in a folder labeled Debug_universal or Release_universal</li>
</ul>
<pre class="brush: bash; title: ; notranslate">
# Version 2.0 (updated for Xcode 4, with some fixes)
# Changes:
#    - Works with xcode 4, even when running xcode 3 projects (Workarounds for apple bugs)
#    - Faster / better: only runs lipo once, instead of once per recursion
#    - Added some debugging statemetns that can be switched on/off by changing the DEBUG_THIS_SCRIPT variable to &quot;true&quot;
#    - Fixed some typos
#
# Purpose:
#   Create a static library for iPhone from within XCode
#   Because Apple staff DELIBERATELY broke Xcode to make this impossible from the GUI (Xcode 3.2.3 specifically states this in the Release notes!)
#   ...no, I don't understand why they did this!
#
# Author: Adam Martin - http://twitter.com/redglassesapps
# Based on: original script from Eonil (main changes: Eonil's script WILL NOT WORK in Xcode GUI - it WILL CRASH YOUR COMPUTER)
#
# More info: see this Stack Overflow question: http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4

#################[ Tests: helps workaround any future bugs in Xcode ]########
#
DEBUG_THIS_SCRIPT=&quot;false&quot;

if [ $DEBUG_THIS_SCRIPT = &quot;true&quot; ]
then
echo &quot;########### TESTS #############&quot;
echo &quot;Use the following variables when debugging this script; note that they may change on recursions&quot;
echo &quot;BUILD_DIR = $BUILD_DIR&quot;
echo &quot;BUILD_ROOT = $BUILD_ROOT&quot;
echo &quot;CONFIGURATION_BUILD_DIR = $CONFIGURATION_BUILD_DIR&quot;
echo &quot;BUILT_PRODUCTS_DIR = $BUILT_PRODUCTS_DIR&quot;
echo &quot;CONFIGURATION_TEMP_DIR = $CONFIGURATION_TEMP_DIR&quot;
echo &quot;TARGET_BUILD_DIR = $TARGET_BUILD_DIR&quot;
fi

#####################[ part 1 ]##################
# First, work out the BASESDK version number (NB: Apple ought to report this, but they hide it)
#    (incidental: searching for substrings in sh is a nightmare! Sob)

SDK_VERSION=$(echo ${SDK_NAME} | grep -o '.\{3\}$')

# Next, work out if we're in SIM or DEVICE

if [ ${PLATFORM_NAME} = &quot;iphonesimulator&quot; ]
then
OTHER_SDK_TO_BUILD=iphoneos${SDK_VERSION}
else
OTHER_SDK_TO_BUILD=iphonesimulator${SDK_VERSION}
fi

echo &quot;XCode has selected SDK: ${PLATFORM_NAME} with version: ${SDK_VERSION} (although back-targetting: ${IPHONEOS_DEPLOYMENT_TARGET})&quot;
echo &quot;...therefore, OTHER_SDK_TO_BUILD = ${OTHER_SDK_TO_BUILD}&quot;
#
#####################[ end of part 1 ]##################

#####################[ part 2 ]##################
#
# IF this is the original invocation, invoke WHATEVER other builds are required
#
# Xcode is already building ONE target...
#
# ...but this is a LIBRARY, so Apple is wrong to set it to build just one.
# ...we need to build ALL targets
# ...we MUST NOT re-build the target that is ALREADY being built: Xcode WILL CRASH YOUR COMPUTER if you try this (infinite recursion!)
#
#
# So: build ONLY the missing platforms/configurations.

if [ &quot;true&quot; == ${ALREADYINVOKED:-false} ]
then
echo &quot;RECURSION: I am NOT the root invocation, so I'm NOT going to recurse&quot;
else
# CRITICAL:
# Prevent infinite recursion (Xcode sucks)
export ALREADYINVOKED=&quot;true&quot;

echo &quot;RECURSION: I am the root ... recursing all missing build targets NOW...&quot;
echo &quot;RECURSION: ...about to invoke: xcodebuild -configuration \&quot;${CONFIGURATION}\&quot; -target \&quot;${TARGET_NAME}\&quot; -sdk \&quot;${OTHER_SDK_TO_BUILD}\&quot; ${ACTION} RUN_CLANG_STATIC_ANALYZER=NO&quot;
xcodebuild -configuration &quot;${CONFIGURATION}&quot; -target &quot;${TARGET_NAME}&quot; -sdk &quot;${OTHER_SDK_TO_BUILD}&quot; ${ACTION} RUN_CLANG_STATIC_ANALYZER=NO BUILD_DIR=&quot;${BUILD_DIR}&quot; BUILD_ROOT=&quot;${BUILD_ROOT}&quot;

ACTION=&quot;build&quot;

#Merge all platform binaries as a fat binary for each configurations.

# Calculate where the (multiple) built files are coming from:
CURRENTCONFIG_DEVICE_DIR=${SYMROOT}/${CONFIGURATION}-iphoneos
CURRENTCONFIG_SIMULATOR_DIR=${SYMROOT}/${CONFIGURATION}-iphonesimulator

echo &quot;Taking device build from: ${CURRENTCONFIG_DEVICE_DIR}&quot;
echo &quot;Taking simulator build from: ${CURRENTCONFIG_SIMULATOR_DIR}&quot;

CREATING_UNIVERSAL_DIR=${SYMROOT}/${CONFIGURATION}-universal
echo &quot;...I will output a universal build to: ${CREATING_UNIVERSAL_DIR}&quot;

# ... remove the products of previous runs of this script
#      NB: this directory is ONLY created by this script - it should be safe to delete!

rm -rf &quot;${CREATING_UNIVERSAL_DIR}&quot;
mkdir &quot;${CREATING_UNIVERSAL_DIR}&quot;

#
echo &quot;lipo: for current configuration (${CONFIGURATION}) creating output file: ${CREATING_UNIVERSAL_DIR}/${EXECUTABLE_NAME}&quot;
lipo -create -output &quot;${CREATING_UNIVERSAL_DIR}/${EXECUTABLE_NAME}&quot; &quot;${CURRENTCONFIG_DEVICE_DIR}/${EXECUTABLE_NAME}&quot; &quot;${CURRENTCONFIG_SIMULATOR_DIR}/${EXECUTABLE_NAME}&quot;

#########
#
# Added: StackOverflow suggestion to also copy &quot;include&quot; files
#    (untested, but should work OK)
#
if [ -d &quot;${CURRENTCONFIG_DEVICE_DIR}/usr/local/include&quot; ]
then
mkdir -p &quot;${CREATING_UNIVERSAL_DIR}/usr/local/include&quot;
# * needs to be outside the double quotes?
cp &quot;${CURRENTCONFIG_DEVICE_DIR}/usr/local/include/&quot;* &quot;${CREATING_UNIVERSAL_DIR}/usr/local/include&quot;
fi
fi
</pre>
]]></content:encoded>
			<wfw:commentRss>http://fredandrandall.com/blog/2011/10/22/building-a-static-library-that-works-on-the-iphone-and-the-simulator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to change the color of UIBarButtonItem on iOS 5</title>
		<link>http://fredandrandall.com/blog/2011/10/15/how-to-change-the-color-of-uibarbuttonitem-on-ios-5/</link>
		<comments>http://fredandrandall.com/blog/2011/10/15/how-to-change-the-color-of-uibarbuttonitem-on-ios-5/#comments</comments>
		<pubDate>Sat, 15 Oct 2011 19:45:26 +0000</pubDate>
		<dc:creator><![CDATA[Randall]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[iOS 5]]></category>
		<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[objc]]></category>

		<guid isPermaLink="false">http://fredandrandall.com/blog/?p=623</guid>
		<description><![CDATA[My most popular blog post is how to change the color of a UIBarButtonItem. It&#8217;s something that lots of people want to do, but it involved some pretty weird hacks to get it working. Now that iOS 5 is out, &#8230; <a href="http://fredandrandall.com/blog/2011/10/15/how-to-change-the-color-of-uibarbuttonitem-on-ios-5/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>My <a href="http://fredandrandall.com/blog/2011/03/31/how-to-change-the-color-of-a-uibarbuttonitem/" title="How to change the color of a UIBarButtonItem">most popular blog post</a> is how to change the color of a UIBarButtonItem. It&#8217;s something that lots of people want to do, but it involved some pretty weird hacks to get it working.</p>
<p>Now that iOS 5 is out, I can talk about a better way to do it. Apple will now let you set the <code>tintColor:</code> property on the bar button item. That&#8217;s it. No more weird hacks with images or segmented controls.</p>
<p>There&#8217;s even a cool new appearance proxy that will let you change all controls from your app with a single line of code. (More about UIAppearance <a href="http://developer.apple.com/library/ios/#documentation/uikit/reference/UIAppearance_Protocol/Reference/Reference.html">here</a>)</p>
<p>So lets say you want every UIBarButtonItem in your application to be blue. That&#8217;s easy just call <code>[UIBarButtonItem appearance] setTintColor:[UIColor blueColor]]</code></p>
<p>Remember, this is iOS 5 only. If you want your app to support iOS 4, you&#8217;ll have to do it <a href="http://fredandrandall.com/blog/2011/03/31/how-to-change-the-color-of-a-uibarbuttonitem/" title="How to change the color of a UIBarButtonItem">the old way</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://fredandrandall.com/blog/2011/10/15/how-to-change-the-color-of-uibarbuttonitem-on-ios-5/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to launch your Mac/iOS app with a custom URL</title>
		<link>http://fredandrandall.com/blog/2011/07/30/how-to-launch-your-macios-app-with-a-custom-url/</link>
		<comments>http://fredandrandall.com/blog/2011/07/30/how-to-launch-your-macios-app-with-a-custom-url/#comments</comments>
		<pubDate>Sat, 30 Jul 2011 23:02:09 +0000</pubDate>
		<dc:creator><![CDATA[Randall]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[custom url]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[MacOS]]></category>
		<category><![CDATA[objc]]></category>

		<guid isPermaLink="false">http://fredandrandall.com/blog/?p=473</guid>
		<description><![CDATA[One interesting feature of iOS and Mac apps is the ability for them to be launched by a custom URL. What this means is that you can set up your app to respond to different links in different ways. Clicking &#8230; <a href="http://fredandrandall.com/blog/2011/07/30/how-to-launch-your-macios-app-with-a-custom-url/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://fredandrandall.com/blog/wp-content/uploads/2011/07/http.jpg"><img class="alignleft size-medium wp-image-488" title="http" src="http://fredandrandall.com/blog/wp-content/uploads/2011/07/http-300x197.jpg" alt="" width="210" height="138" /></a>One interesting feature of iOS and Mac apps is the ability for them to be launched by a custom URL. What this means is that you can set up your app to respond to different links in different ways.</p>
<p>Clicking a link that says myTwitterApp://sendTweet?tweet=hello could send a tweet from your twitter app. It could also be used for configuring your app. Maybe you have an email app that needs some special server configurations. It could be set up so that you just have to visit a webpage on your server and click a link and have it automatically configure your email settings.</p>
<p>Facebook uses the URL scheme for authentication in their iPhone app. If I have an app that wants to authenticate with Facebook, it will try and talk to the Facebook app on the phone so I don&#8217;t have to authenticate again in my other app.</p>
<p>I think this is a pretty underused feature and I would bet there are TONS of clever things people can do with it. So how do you actually do it?<span id="more-473"></span></p>
<p>I&#8217;m going to show you how I&#8217;m adding it to the next versions of Thoughtback.</p>
<p>Your first step is adding a URL type to your app&#8217;s info.plist. You will add the same key if you&#8217;re making an iOS or Mac app. The raw key is CFBundleURLTypes.</p>
<p><a href="http://fredandrandall.com/blog/wp-content/uploads/2011/07/urltype.png"><img class="aligncenter size-medium wp-image-474" title="urltype" src="http://fredandrandall.com/blog/wp-content/uploads/2011/07/urltype-300x66.png" alt="" width="300" height="66" /></a></p>
<p>Once the key is added links that start with thoughtback:// will launch the apps on both iOS and OS X.</p>
<p>Just launching from a URL is fine, but how do you get any information out of the URL that was clicked? That&#8217;s where the process differs between the two platforms.</p>
<p><strong>iOS</strong><br />
Go into your applicationdelegate and override either of these two methods.</p>
<pre>- (BOOL)application:(UIApplication *)application 
           handleOpenURL:(NSURL *)url

- (BOOL)application:(UIApplication *)application 
            openURL:(NSURL *)url 
  sourceApplication:(NSString*)sourceApplication 
         annotation:(id)annotation</pre>
<p><em></em>I should mention that the first method is deprecated, but the second one is only available on iOS 4.2 or later.</p>
<p><strong>Mac OS</strong><br />
This is slightly different on the mac, URL handling is not part of the NSApplicationDelegate protocol.</p>
<p>What you&#8217;ll need to do is tell the application to respond to an Apple Event.</p>
<pre class="brush: objc; title: ; notranslate">
-(void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
    NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];
    [appleEventManager setEventHandler:self
                           andSelector:@selector(handleGetURLEvent:withReplyEvent:)
                         forEventClass:kInternetEventClass andEventID:kAEGetURL];
}

- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
    NSURL *url = [NSURL URLWithString:[[event paramDescriptorForKeyword:keyDirectObject] stringValue]];
}
</pre>
<p><strong>Parsing the URL</strong><br />
So now that you have the URL that launched your app, you&#8217;ll want to get the information out of the string. The most typical way to send information is with a query string. Here&#8217;s an example that Thoughtback will use.</p>
<p>thoughtback://send?thought=Interesting Thought&amp;redirect=http://fredandrandall.com</p>
<p>We want to pull out a few different things from that. First we want to grab &#8220;send&#8221; because that&#8217;s the action thoughtback will take. Then we want to get the thought that will be sent and the url that Thoughtback will redirect to when it&#8217;s done sending the thought.</p>
<p>To parse out &#8220;send&#8221; we can use NSURL&#8217;s host method.</p>
<p>To get the query string, we can use NSURL&#8217;s query method.</p>
<p>Parsing the query string is a little more difficult but this block of code, that I found on <a href="http://stackoverflow.com/questions/6591280/how-to-parse-an-asset-url-in-objective-c">StackOverflow</a>, will put it into an NSDictionary for you.</p>
<pre class="brush: objc; title: ; notranslate">
NSString *query = [url query];
NSArray *queryPairs = [query componentsSeparatedByString:@&quot;&amp;&quot;];
NSMutableDictionary *pairs = [NSMutableDictionary dictionary];
for (NSString *queryPair in queryPairs) {
  NSArray *bits = [queryPair componentsSeparatedByString:@&quot;=&quot;];
  if ([bits count] != 2) { continue; }

  NSString *key = [[bits objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  NSString *value = [[bits objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

  [pairs setObject:value forKey:key];
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://fredandrandall.com/blog/2011/07/30/how-to-launch-your-macios-app-with-a-custom-url/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What I learned from working with my first client</title>
		<link>http://fredandrandall.com/blog/2011/04/30/what-i-learned-from-working-with-my-first-client/</link>
		<comments>http://fredandrandall.com/blog/2011/04/30/what-i-learned-from-working-with-my-first-client/#comments</comments>
		<pubDate>Sat, 30 Apr 2011 17:33:44 +0000</pubDate>
		<dc:creator><![CDATA[Randall]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[GoMongo]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iPhone SDK]]></category>

		<guid isPermaLink="false">http://fredandrandall.com/blog/?p=352</guid>
		<description><![CDATA[A few months ago I was contacted by a friend of a friend on Facebook who owns a local creative marketing agency. He knew I had made the Thoughtback iPhone app and was wondering if I&#8217;d be interested in doing &#8230; <a href="http://fredandrandall.com/blog/2011/04/30/what-i-learned-from-working-with-my-first-client/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://fredandrandall.com/blog/wp-content/uploads/2011/04/BDsforBlog.png"><img class="alignleft size-medium wp-image-346" title="BDsforBlog" src="http://fredandrandall.com/blog/wp-content/uploads/2011/04/BDsforBlog-154x300.png" alt="" width="154" height="300" /></a>A few months ago I was contacted by a friend of a friend on Facebook who owns a local creative marketing agency. He knew I had made the Thoughtback iPhone app and was wondering if I&#8217;d be interested in doing some work on an iPhone app for him. I decided to head down to his office and find out more.</p>
<p>At that first meeting, he told me that <a href="http://www.gomongo.com">bd&#8217;s Mongolian Grill</a>, one of their clients, wanted an iPhone app and they had no idea how to make one. That was where I came in. We talked a lot about the whole process of building an app and what was even possible to do with an iPhone. I was expecting something more like a job interview, but was surprised when it wasn&#8217;t. They told me that they were going to talk about what features they wanted to put in the app and get back to me.</p>
<p>A few days later, I came in again to talk about the features that they wanted to add and to see if what they wanted was realistic. At this point I wasn&#8217;t sure if I was going to be making the app or if they were evaluating me. I guess they had pretty much already decided I would be hired, since either at that meeting or in an email right after, they asked how much I would charge to build this app for them.</p>
<p><span id="more-352"></span></p>
<p><strong>How much should I charge?</strong></p>
<p>How much to charge is a really hard question. On one hand, I wanted them to hire me and was afraid that if I charged too much they&#8217;d try to find someone else. On the other hand, I&#8217;m a qualified, professional, software engineer and my time is worth real money. I was really hoping they were going to make me an offer so I wouldn&#8217;t have to come up with the number myself.</p>
<p>I did some googling and found some crazy numbers. <a href="http://stackoverflow.com/questions/209170/how-much-does-it-cost-to-develop-an-iphone-application">People</a> were saying anywhere from $10,000 &#8211; $50,000. I tried doing an estimate of how many hours it would take and then multiplying it by what I get payed at my day job. All these numbers seemed unreasonable to me. $10,000 dollars is a TON of money. Remember, this is NOT how I make my living so I don&#8217;t actually need the money, it&#8217;s all gravy. I ended up picking a number that would let me take a couple pretty awesome vacations, but still not be unreasonable for a smaller company to pay. I think I lowballed myself a little bit because obviously development takes longer than you think.</p>
<p><strong>You&#8217;re worth more than you think!</strong></p>
<p>If I had any advice for someone else in my situation, pick a number that seems just a <em>little</em> bit too high. Remember, you can&#8217;t get money you don&#8217;t ask for. Don&#8217;t worry if it&#8217;s something you haven&#8217;t done before. Odds are good that you can. One of the reasons I think I went low is because I wasn&#8217;t sure I could actually do what they wanted. Now that I actually finished it, that seems silly because I was able to do everything they wanted (and more).</p>
<p><strong>How long is this going to take?</strong></p>
<p>Of course, with the money estimate, they wanted a time estimate. This was another tough one. I had never done an iPhone app of this scale before. They wanted lots of stuff that I&#8217;ve never done before like Facebook sharing, Twitter sharing, and use of the iPhone&#8217;s Camera. So I went through each feature and figured out how long I thought it should take in hours. Then I added a little padding time because everything always takes longer than expected. Thankfully, my client understood that too and added some more padding of their own onto the deadline.</p>
<p><strong>You suck at estimating!</strong></p>
<p>Well, maybe you don&#8217;t, but I do and so do most other people I know. There are always a ton of factors you don&#8217;t think about when making that first estimate. In my case, I was thinking I would spend about 2 hours a day working on the app after I got home from work. What I wasn&#8217;t thinking about was my weeklong vacation to Florida and all of the time I wanted to spend having a life (hanging out with my girlfriend, playing video games, going to movies, etc.). So towards the end of the project, 2 hours a day turned into 3 or 4 and some weekends were even longer. I also wasn&#8217;t anticipating all of the changes that my client would want me to make. I had to completely change some functionality mid way through because they wanted something different. This brings me to my next point.</p>
<p><strong>Working for a client is NOT like working for a company that sells software!</strong></p>
<p>Where I work, we don&#8217;t have clients. We sell software to consumers. Our deadlines are self imposed and we have to come up with our own specs. When you work with a client, they set deadlines and they tell you what they want in the app. They get what they want, because they&#8217;re paying for it.</p>
<p><strong>Will you do it again?</strong></p>
<p>Hmmm, it&#8217;s hard to say. This has been a very positive experience. It&#8217;s a great way to pull in some extra spending cash and I learned a TON about iPhone development. The company I worked with was really great. We kept in constant communication the whole time and they gave me a lot of freedom in finishing out some small parts of the design that weren&#8217;t in their mockups.</p>
<p>Even though it was awesome, it was a lot of work. I don&#8217;t really <em>need</em> the money and as much as I like doing development on the side, it&#8217;s nice to be able to set something down when I want to.</p>
<p>I would recommend any developer with some spare time to try something like this at least once. I really learned a lot, not just about development, but about communication and working with others.</p>
]]></content:encoded>
			<wfw:commentRss>http://fredandrandall.com/blog/2011/04/30/what-i-learned-from-working-with-my-first-client/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to change the color of a UIBarButtonItem</title>
		<link>http://fredandrandall.com/blog/2011/03/31/how-to-change-the-color-of-a-uibarbuttonitem/</link>
		<comments>http://fredandrandall.com/blog/2011/03/31/how-to-change-the-color-of-a-uibarbuttonitem/#comments</comments>
		<pubDate>Thu, 31 Mar 2011 23:12:08 +0000</pubDate>
		<dc:creator><![CDATA[Randall]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[objc]]></category>
		<category><![CDATA[UIBarButtonItem]]></category>
		<category><![CDATA[UISegmentedControl]]></category>

		<guid isPermaLink="false">http://fredandrandall.com/blog/?p=310</guid>
		<description><![CDATA[EDIT: There is a new way to do this in iOS 5 that is much easier and nicer. If you want to support iOS 4, keep reading. A UIBarButtonItem is an item that goes on a UIToolbar or a UINavigationBar. &#8230; <a href="http://fredandrandall.com/blog/2011/03/31/how-to-change-the-color-of-a-uibarbuttonitem/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://fredandrandall.com/blog/wp-content/uploads/2011/03/UIBarButtonItemTint.png"><img class="alignleft size-medium wp-image-316" title="UIBarButtonItemTint" src="http://fredandrandall.com/blog/wp-content/uploads/2011/03/UIBarButtonItemTint-154x300.png" alt="" width="154" height="300" /></a></p>
<p><strong>EDIT: There is a <a title="How to change the color of UIBarButtonItem on iOS 5" href="http://fredandrandall.com/blog/2011/10/15/how-to-change-the-color-of-uibarbuttonitem-on-ios-5/">new way to do this</a> in iOS 5 that is much easier and nicer. If you want to support iOS 4, keep reading.</strong></p>
<p>A UIBarButtonItem is an item that goes on a UIToolbar or a UINavigationBar. It&#8217;s typically a button but it can be a bunch of different things. I&#8217;m going to talk about the button. A UIBarButtonItem button takes on the color of the bar that it is on. You can set the tint of a UIToolbar, but you can&#8217;t change the colors of the buttons on it.</p>
<p>I found lots of different solutions for this online, most involving adding a UIButton as the customView of the UIBarButtonItem and having some sort of image for the color you need. That works fine, until you need a color that you don&#8217;t have an image for.</p>
<p>I found a better solution <a href="http://charles.lescampeurs.org/2011/02/10/tint-color-uibutton-and-uibarbuttonitem">here</a>. Basically what they figured out was that a UISegmentedControl with a style of UISegmentedControlStyleBar looks just like a UIBarButtonItem. A key difference is that UISegmentedControl has a nice <a href="http://developer.apple.com/library/ios/DOCUMENTATION/UIKit/Reference/UISegmentedControl_Class/Reference/UISegmentedControl.html#//apple_ref/occ/instp/UISegmentedControl/tintColor">tintColor</a> property that you can use to change the colors.</p>
<p>So what I did was take <a href="https://github.com/CharlyBr/MrBrown-Blob">CharlyBr</a>&#8216;s code and put it into a UIBarButtonItem category.</p>
<pre class="brush: objc; title: ; notranslate">
+(UIBarButtonItem*)barButtonItemWithTint:(UIColor*)color andTitle:(NSString*)itemTitle andTarget:(id)theTarget andSelector:(SEL)selector
{
	UISegmentedControl *button = [[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:itemTitle, nil]] autorelease];
	button.momentary = YES;
	button.segmentedControlStyle = UISegmentedControlStyleBar;
	button.tintColor = color;
	[button addTarget:theTarget action:selector forControlEvents:UIControlEventValueChanged];

	UIBarButtonItem *removeButton = [[[UIBarButtonItem alloc] initWithCustomView:button] autorelease];

	return removeButton;
}
</pre>
<p>You can check out my example project on <a href="https://github.com/blladnar/UIBarButtonItem-Tint">GitHub</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://fredandrandall.com/blog/2011/03/31/how-to-change-the-color-of-a-uibarbuttonitem/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Simple imgur iPhone Uploader</title>
		<link>http://fredandrandall.com/blog/2011/02/26/simple-imgur-iphone-uploader/</link>
		<comments>http://fredandrandall.com/blog/2011/02/26/simple-imgur-iphone-uploader/#comments</comments>
		<pubDate>Sat, 26 Feb 2011 23:01:27 +0000</pubDate>
		<dc:creator><![CDATA[Randall]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[imgur]]></category>
		<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[objc]]></category>
		<category><![CDATA[uploader]]></category>

		<guid isPermaLink="false">http://fredandrandall.com/blog/?p=259</guid>
		<description><![CDATA[Recently I&#8217;ve been toying with the idea of adding image uploading to Thoughtback. One easy way to do that is to use another image host and just post a link in the thought. I decided to try out imgur because &#8230; <a href="http://fredandrandall.com/blog/2011/02/26/simple-imgur-iphone-uploader/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://fredandrandall.com/blog/wp-content/uploads/2011/02/imgurimage.png"><img class="alignleft size-full wp-image-275" title="imgurimage" src="http://fredandrandall.com/blog/wp-content/uploads/2011/02/imgurimage.png" alt="" width="333" height="134" /></a>Recently I&#8217;ve been toying with the idea of adding image uploading to <a href="http://www.thoughtback.com">Thoughtback</a>. One easy way to do that is to use another image host and just post a link in the thought. I decided to try out <a href="http://www.imgur.com">imgur</a> because of their <a href="http://api.imgur.com/resources_anon">Anonymous API</a>. What it lets you do is upload images to their service, without requiring a username and password. This is great if you just want quick and easy image sharing.</p>
<p>To get started imgur has some good <a href="http://api.imgur.com/examples">examples</a> of how to upload in a variety of programming languages. I grabbed the iPhone example and copy and pasted it in thinking, &#8220;Well that was easy&#8221;. It turns out there was a little bit more to do.</p>
<p><span id="more-259"></span>Here is the iOS example from their website (with a few typos corrected)</p>
<pre class="brush: objc; title: ; notranslate">
-(NSData *)uploadPhoto:(UIImage *) image {
       NSData   *imageData  = UIImageJPEGRepresentation(image,1);
       NSString *imageB64   = [self escapeString:[imageData base64Encoding]];  //Custom implementations, no built in base64 or HTTP escaping for iPhone
       NSString *uploadCall = [NSStringstringWithFormat:@&quot;key=%@ℑ=%@&quot;,imgurKey,imageB64];

       NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@&quot;http://api.imgur.com/2/upload&quot;]];
       [request setHTTPMethod:@&quot;POST&quot;];
       [request setValue:[NSString stringWithFormat:@&quot;%d&quot;,[uploadCalllength]] forHTTPHeaderField:@&quot;Content-length&quot;];
       [request setHTTPBody:[uploadCall dataUsingEncoding:NSUTF8StringEncoding]];

       NSURLResponse *response;
       NSError *error = nil;

       NSData *XMLResponse= [NSURLConnection sendSynchronousRequest:requestreturningResponse:&amp;response error:&amp;error];

       return XMLResponse;
}
</pre>
<p>The problem with their example was that it wasn&#8217;t quite finished.<br />
<a href="http://fredandrandall.com/blog/wp-content/uploads/2011/02/apiProblem1.png"><img class="aligncenter size-full wp-image-267" title="apiProblem" src="http://fredandrandall.com/blog/wp-content/uploads/2011/02/apiProblem1.png" alt="" width="614" height="60" /></a>That <code>Database64Encoding</code> method is not a part of the iOS sdk. You need to do that yourself. So what does it mean exactly?</p>
<p>It means that you need to convert the image data to <a href="http://en.wikipedia.org/wiki/Base64">Base64</a>. That basically means turning your image data into a string so it can be sent up via a POST request. So I did a little bit of Googling and found some code that converts NSData to a Base64 NSString. I got the code from the <a href="http://mattgemmell.com/2008/02/22/mgtwitterengine-twitter-from-cocoa">MGTwitterEngine</a>, but it can be found in a few places.</p>
<p>So after that I thought I should be done. I ran the code and got an error back from imgur. Then I noticed the weird ℑ character in the request. I&#8217;m not sure what it&#8217;s for, but it didn&#8217;t work. I replaced it with &#8220;image&#8221; and I got a success back from imgur.</p>
<p>Hooray, everything seemed like it was working, but it still wasn&#8217;t. When I went to the URL in the response, there was no image. Nothing loaded. What was wrong?</p>
<p>I had a suspicion that there was some funny stuff going on with the encoding so I wrote the base64 encoded string out to a file (it was waaaay too long for NSLog to handle) to see what was actually in it. There were a bunch of /&#8217;s and +&#8217;s. These are valid URL characters that can definitely mess up query string parsing if you want them to be in one of your arguments.</p>
<p>I pulled out an NSString category I had written to escape valid URL characters and called my <code>stringByEscapingValidURLCharacters</code> method on the base64 string. After trying again I was getting valid stuff back and my image URLs were loading correctly.</p>
<p>So, to prevent others from going through the headaches to make a simple imgur uploader, I decided to open source some example code code.</p>
<p>This code is very simplistic. It is a simple iPhone app that lets you choose an image from the camera or your phone&#8217;s library and send it to imgur. The ImgurUploader class calls out to imgur and returns the URL of the original sized image by calling a delegate method. It doesn&#8217;t handle any errors right now either. You will also need to get an <a href="http://imgur.com/register/api/">API key</a> from imgur, which only takes a second. This comes with the &#8220;works on my machine&#8221; <a href="http://www.codinghorror.com/blog/2007/03/the-works-on-my-machine-certification-program.html">seal</a> of approval.</p>
<p><a href="https://github.com/blladnar/iPhone-Imgur-Uploader">Check it out on GitHub</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fredandrandall.com/blog/2011/02/26/simple-imgur-iphone-uploader/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to use a high res application icon on the iPhone 4</title>
		<link>http://fredandrandall.com/blog/2010/11/04/how-to-use-a-high-res-application-icon-on-the-iphone-4/</link>
		<comments>http://fredandrandall.com/blog/2010/11/04/how-to-use-a-high-res-application-icon-on-the-iphone-4/#comments</comments>
		<pubDate>Fri, 05 Nov 2010 00:15:17 +0000</pubDate>
		<dc:creator><![CDATA[Randall]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[app store submission]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[objc]]></category>
		<category><![CDATA[retina display]]></category>

		<guid isPermaLink="false">http://fredandrandall.com/blog/?p=134</guid>
		<description><![CDATA[One of the iPhone 4&#8217;s coolest feature is the retina display. It is just so much more clear and crisp than any other screen I&#8217;ve ever seen. The clarity of the screen makes it extra important for you to use &#8230; <a href="http://fredandrandall.com/blog/2010/11/04/how-to-use-a-high-res-application-icon-on-the-iphone-4/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://fredandrandall.com/blog/wp-content/uploads/2010/11/hiresiconblogpost.png"><img class="alignleft size-full wp-image-139" title="hiresiconblogpost" src="http://fredandrandall.com/blog/wp-content/uploads/2010/11/hiresiconblogpost.png" alt="" width="253" height="250" /></a>One of the iPhone 4&#8217;s coolest feature is the retina display. It is just so much more clear and crisp than any other screen I&#8217;ve ever seen. The clarity of the screen makes it extra important for you to use a high res icon for your app. Doing that is a little trickier than I expected.</p>
<p>If you saw my earlier <a href="http://fredandrandall.com/blog/2010/10/29/hi-res-icon-issues/">post</a> on how to use high res images in your app, you might expect the app icon to be the same. Unfortunately it isn&#8217;t, at least not exactly. At first, I just put in the high res icon. That seemed fine. Everything looked good and all was well. Until I submitted it to the app store. Upon submission, I got an error saying that I needed to provide an icon that was 57&#215;57 pixels. That low resolution doesn&#8217;t look so great on the iPhone 4.</p>
<p>So I did what I did for my other images. I created a 57&#215;57 icon file called appicon.png and a 114&#215;114 icon file called appicon@2x.png thinking that it would automatically load the high res icon on the iPhone 4. This was not the case, it only loaded the low res version.</p>
<p>Here&#8217;s how I got it working.</p>
<p><span style="font-size: 13px; font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: 19px;"><span id="more-134"></span></span>There is another value in your info.plist for icons. It is CFBundleIconFiles. Apple added this because there were beginning to be a semi-ridiculous amount of icons for iPhone/iPad apps. There is the app icon and the search icon, but with the iPad and iPhone 4 you have 4 more icons you need to have since they&#8217;re all different resolutions.  It&#8217;s a problem that I think Apple could solve a little bit more elegantly.</p>
<p><a href="http://fredandrandall.com/blog/wp-content/uploads/2010/11/Screen-shot-2010-11-04-at-8.07.14-PM.png"><img class="aligncenter size-full wp-image-141" title="Screen shot 2010-11-04 at 8.07.14 PM" src="http://fredandrandall.com/blog/wp-content/uploads/2010/11/Screen-shot-2010-11-04-at-8.07.14-PM.png" alt="" width="368" height="61" /></a>So there you go, just put that into your apps info.plist instead of the default icon key and everything should be fine. Hopefully this will prevent you from having the minor headache it caused me.</p>
]]></content:encoded>
			<wfw:commentRss>http://fredandrandall.com/blog/2010/11/04/how-to-use-a-high-res-application-icon-on-the-iphone-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
