<?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>[iPhone developer:tips];</title>
	<atom:link href="http://iPhoneDeveloperTips.com/feed" rel="self" type="application/rss+xml" />
	<link>http://iPhoneDeveloperTips.com</link>
	<description>Tips and Tricks for iPhone developers</description>
	<lastBuildDate>Thu, 11 Mar 2010 14:32:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Voices That Matter iPhone Developers Conference – Enter in the Drawing for a Free 2-Day Pass</title>
		<link>http://iPhoneDeveloperTips.com/giveaway/voices-that-matter-iphone-developers-conference-%e2%80%93-enter-in-the-drawing-for-a-free-2-day-pass.html</link>
		<comments>http://iPhoneDeveloperTips.com/giveaway/voices-that-matter-iphone-developers-conference-%e2%80%93-enter-in-the-drawing-for-a-free-2-day-pass.html#comments</comments>
		<pubDate>Thu, 11 Mar 2010 07:03:38 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[Giveaway]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=5811</guid>
		<description><![CDATA[I previously announced that Voices That Matter is hosting another iPhone Developer Conference, with this event being held in Seattle, WA. As part of that post, I mentioned that Voices That Matter and iPhone Dev Tips are giving away one free 2-day pass, a pretty good deal as the full admission price is $695.
Originally the [...]]]></description>
			<content:encoded><![CDATA[<p>I previously announced that <a href="http://iphonedevelopertips.com/announcements/voices-that-matter-iphone-developers-conference-register-to-win-a-free-pass.html">Voices That Matter is hosting another iPhone Developer Conference</a>, with this event being held in Seattle, WA. As part of that post, I mentioned that Voices That Matter and iPhone Dev Tips are giving away one free 2-day pass, a pretty good deal as the full admission price is $695.</p>
<p>Originally the drawing for the giveaway was to be held March 12th, however, given that the event is still 6+ weeks out, it seems to make sense to extend the deadline for submitting entries.</p>
<h5>How the Contest Works</h5>
<p>If you are interested to register for the drawing, all you need to do is click the Refer-A-Friend button below and fill in the popup form to refer one or more friends to this blog post. Make sure your email address is correct in the form, as that will be your ticket in the drawing. It’s that simple! I respect your privacy, your email will be used only for registration in the event.</p>
Note: There is an email link embedded within this post, please visit this post to email it.
<h5>The Details</h5>
<p>The deadline to register for the drawing is March 24th, 2010. The winner will be announced on March 25th, 2010. The drawing is for one free admission pass only, you will have to pay any additional travel or related expenses.</p>
<p>Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/giveaway/voices-that-matter-iphone-developers-conference-%e2%80%93-enter-in-the-drawing-for-a-free-2-day-pass.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Send Email with Attachments &#8211; Example Using iPhone Camera to Email a Photo</title>
		<link>http://iPhoneDeveloperTips.com/email/how-to-send-email-with-attachments-example-using-iphone-camera-to-email-a-photo.html</link>
		<comments>http://iPhoneDeveloperTips.com/email/how-to-send-email-with-attachments-example-using-iphone-camera-to-email-a-photo.html#comments</comments>
		<pubDate>Wed, 10 Mar 2010 08:03:12 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[Email]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=5772</guid>
		<description><![CDATA[In this post: Camera Application to Take Pictures and Save Images to Photo Album, I demonstrated how you can take photos with the iPhone camera and save the captured images to the Photo Album. A reader asked if it would be possible to email the camera image in place of writing to the Photo Album, [...]]]></description>
			<content:encoded><![CDATA[<p>In this post: <a href="http://iphonedevelopertips.com/camera/camera-application-to-take-pictures-and-save-images-to-photo-album.html">Camera Application to Take Pictures and Save Images to Photo Album</a>, I demonstrated how you can take photos with the iPhone camera and save the captured images to the Photo Album. A reader asked if it would be possible to email the camera image in place of writing to the Photo Album, which is the focus of this tip. </p>
<p>Building on the previous post, the example created here starts the camera on the iPhone, and once a photo is snapped, launches the email application, attaching the resulting image to the email.</p>
<h5>Start the iPhone Camera</h5>
<p>The user interface of this application is quite simple, there is one button on the UI that will start the camera. Once the button is tapped, the method shown below will be called. Here we create an image picker controller, set the source type to the camera, point the delegate to self and specify not to allow image editing. From there, simply show a modal view controller to enable the camera.</p>

<div class="wp_syntax"><div 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>buttonPressed<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIButton <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>button
<span style="color: #002200;">&#123;</span>
  <span style="color: #11740a; font-style: italic;">// Create image picker controller</span>
  UIImagePickerController <span style="color: #002200;">*</span>imagePicker <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIImagePickerController alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Set source to the camera</span>
  imagePicker.sourceType <span style="color: #002200;">=</span>  UIImagePickerControllerSourceTypeCamera;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Delegate is self</span>
  imagePicker.delegate <span style="color: #002200;">=</span> self;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Allow editing of image ?</span>
  imagePicker.allowsImageEditing <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Show image picker</span>
  <span style="color: #002200;">&#91;</span>self presentModalViewController<span style="color: #002200;">:</span>imagePicker animated<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;	
<span style="color: #002200;">&#125;</span></pre></div></div>

<h5>Convert Camera Image to NSData Object</h5>
<p>Once the camera has taken a photo, the method below will be called, passing in a dictionary of related information, such as the original image, edited image (if any), URL to a movie (when applicable), etc. We grab the image from the dictionary and create a <strong>UIImage</strong> object. From there, dismiss the camera, then pass the camera image to the method <strong>emailImage</strong> where we will construct an email and append the image.</p>

<div class="wp_syntax"><div 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> imagePickerController<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIImagePickerController <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>picker didFinishPickingMediaWithInfo<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSDictionary</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>info
<span style="color: #002200;">&#123;</span>
  <span style="color: #11740a; font-style: italic;">// Access the uncropped image from info dictionary</span>
  UIImage <span style="color: #002200;">*</span>image <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>info objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;UIImagePickerControllerOriginalImage&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Dismiss the camera</span>
  <span style="color: #002200;">&#91;</span>self dismissModalViewControllerAnimated<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Pass the image from camera to method that will email the same</span>
  <span style="color: #11740a; font-style: italic;">// A delay is needed so camera view can be dismissed</span>
  <span style="color: #002200;">&#91;</span>self performSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>emailImage<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span> withObject<span style="color: #002200;">:</span>image afterDelay<span style="color: #002200;">:</span><span style="color: #2400d9;">1.0</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Release picker</span>
  <span style="color: #002200;">&#91;</span>picker release<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<h5>Email Camera Image</h5>
<p>The last step is to compose an email and attach the image from the camera. We begin be creating a <strong>MFMailComposeViewController</strong> object, setting the delegate to self. We then step through the configuration preferences for the email, setting the subject, the list of recipients (to, carbon copy, and blind carbon copy) and creating the body of the message.</p>
<p>Our next step is to convert the<strong>UIImage</strong> from the camera into an NSData object, which we can attach to our email. As you&#8217;ll notice in the code below, I&#8217;ve created the <strong>NSData</strong> as a PNG representation, you could also use JPG format if you prefer (which allows you to specify a value for image compression). </p>
<p>Once the image is attached to the email, we show a modal view controller which will launch the email application &#8211; one note, I am making the assumption that iPhone OS 3.x is the active platform.</p>

<div class="wp_syntax"><div 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>emailImage<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIImage <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>image
<span style="color: #002200;">&#123;</span>
  MFMailComposeViewController <span style="color: #002200;">*</span>picker <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>MFMailComposeViewController alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
  picker.mailComposeDelegate <span style="color: #002200;">=</span> self;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Set the subject of email</span>
  <span style="color: #002200;">&#91;</span>picker setSubject<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Picture from my iPhone!&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Add email addresses</span>
  <span style="color: #11740a; font-style: italic;">// Notice three sections: &quot;to&quot; &quot;cc&quot; and &quot;bcc&quot;	</span>
  <span style="color: #002200;">&#91;</span>picker setToRecipients<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> arrayWithObjects<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;emailaddress1@domainName.com&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;emailaddress2@domainName.com&quot;</span>, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
  <span style="color: #002200;">&#91;</span>picker setCcRecipients<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> arrayWithObject<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;emailaddress3@domainName.com&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;	
  <span style="color: #002200;">&#91;</span>picker setBccRecipients<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> arrayWithObject<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;emailaddress4@domainName.com&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Fill out the email body text</span>
  <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>emailBody <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;I just took this picture, check it out.&quot;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// This is not an HTML formatted email</span>
  <span style="color: #002200;">&#91;</span>picker setMessageBody<span style="color: #002200;">:</span>emailBody isHTML<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Create NSData object as PNG image data from camera image</span>
  <span style="color: #400080;">NSData</span> <span style="color: #002200;">*</span>data <span style="color: #002200;">=</span> UIImagePNGRepresentation<span style="color: #002200;">&#40;</span>image<span style="color: #002200;">&#41;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Attach image data to the email</span>
  <span style="color: #11740a; font-style: italic;">// 'CameraImage.png' is the file name that will be attached to the email</span>
  <span style="color: #002200;">&#91;</span>picker addAttachmentData<span style="color: #002200;">:</span>data mimeType<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;image/png&quot;</span> fileName<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;CameraImage&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Show email view	</span>
  <span style="color: #002200;">&#91;</span>self presentModalViewController<span style="color: #002200;">:</span>picker animated<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Release picker</span>
  <span style="color: #002200;">&#91;</span>picker release<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>mailComposeController<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>MFMailComposeViewController<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>controller didFinishWithResult<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>MFMailComposeResult<span style="color: #002200;">&#41;</span>result error<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSError</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>error 
<span style="color: #002200;">&#123;</span>
  <span style="color: #11740a; font-style: italic;">// Called once the email is sent</span>
  <span style="color: #11740a; font-style: italic;">// Remove the email view controller	</span>
  <span style="color: #002200;">&#91;</span>self dismissModalViewControllerAnimated<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<h5>Caveat</h5>
<p>To keep things simple, this application runs on a single thread. It works fine, however, there is a few second delay when moving from the camera application to the email application. Ideally you would add a little logic to better manage the user interface.</p>
<h5>Source Code</h5>
<p>Here is the link to the source code: <a href="http://iphonedevelopertips.com/wp-content/uploads/2010/03/cameraEmail.zip">Email Camera Image Application</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/email/how-to-send-email-with-attachments-example-using-iphone-camera-to-email-a-photo.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone Development Mentoring Now Available</title>
		<link>http://iPhoneDeveloperTips.com/training/iphone-development-mentoring-now-available.html</link>
		<comments>http://iPhoneDeveloperTips.com/training/iphone-development-mentoring-now-available.html#comments</comments>
		<pubDate>Sun, 07 Mar 2010 15:35:57 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[Training]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[mentor]]></category>
		<category><![CDATA[mentoring]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=5692</guid>
		<description><![CDATA[A good friend once described the process of learning iPhone development as having a &#8220;high-barrier to entry.&#8221; It&#8217;s not that iPhone development is any more difficult than any other platform, rather, it has to do with the fact that most everything is typically new to developers interested in coding iPhone apps: the programming language (Objective-C), [...]]]></description>
			<content:encoded><![CDATA[<p>A good friend once described the process of learning iPhone development as having a &#8220;high-barrier to entry.&#8221; It&#8217;s not that iPhone development is any more difficult than any other platform, rather, it has to do with the fact that most everything is typically new to developers interested in coding iPhone apps: the programming language (Objective-C), the development tools (Xcode, Instruments, Interface Builder), the extensive API&#8217;s and navigating the iPhone development and deployment process.</p>
<p>In over 20 years of software development, I&#8217;ve delivered 1000+ hours of developer training. No question, classroom training can be helpful to learn a new programming language and related tools. On the other hand, with few exceptions, course content and delivery is not tailored to your specific development experience and needs, which can result in a loss of focus and time spent on areas that are not relevant to your projects.</p>
<p>Regardless of the platform and tools, in my experience, one of the most effective ways to get up to speed quickly is to work alongside an experienced developer. With that in mind, I am offering customized mentoring for developers interested to learn iPhone application development.</p>
<p>You decide what&#8217;s important to you, based on your projects and current skill set. Unlike classroom training, the content is entirely your call.</p>
<p><strong>Potential topics:</strong></p>
<p>• Effective wireframes (tools and approaches)<br />
• Creating wireframe/specification for your project<br />
• Getting up to speed with Xcode<br />
• Objective-C crash course<br />
• Code walk-through of working applications<br />
• Developer program registration, profiles and certificates<br />
• Creating and distributing adhoc/beta builds<br />
• Deployment process and tips<br />
• Working with the simulator<br />
• Playing audio and video content<br />
• Calling web-services, using JSON<br />
• Working with property lists (plists)<br />
• Recommended open source projects (with code examples)<br />
• Any other topics you need&#8230;</p>
<p><strong>Benefits of mentoring:</strong></p>
<p>• Focus on your specific needs and interests<br />
• Working with an experienced iPhone developer<br />
• Delivered on site, working in your environment<br />
• More effective than classroom training</p>
<p><strong>A little more about my background:</strong></p>
<p>• Extensive experience teaching developers<br />
• Over 20 published iPhone applications (from Snoop Dogg to Star Wars)<br />
   &nbsp;&nbsp;&nbsp;Visit <a  target="_blank"  href="http://3SixtySoftware.com">3SixtySoftware.com</a> for more information about my apps<br />
• 20+ years designing and developing software<br />
• Published author including a <a href="http://www.amazon.com/gp/product/0130669113?ie=UTF8&#038;tag=iphonedevelopertips-20&#038;link_code=as3&#038;camp=211189&#038;creative=373489&#038;creativeASIN=0130669113">best-selling mobile developer book</a></p>
<p><strong>Pricing:</strong></p>
<p>My objective is to provide a very effective learning process at a reasonable price, offering one-on-one guidance that isn&#8217;t available in traditional classroom training. Rates for mentoring are based on the number of developers involved &#8211; I recommend mentoring be limited to 1-3 individuals which will keep the pace moving quickly. Any travel related expenses would be additional.</p>
<p><strong>For more information:<br />
</strong><br />
To learn more, including pricing and scheduling availability, please contact me by email: <em><strong>John at 3SixtySoftware dot com</strong></em> or fill out this <a href="http://iphonedevelopertips.com/contact">Contact Form</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/training/iphone-development-mentoring-now-available.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Save UIImage Object as a PNG or JPEG File</title>
		<link>http://iPhoneDeveloperTips.com/data-file-management/save-uiimage-object-as-a-png-or-jpeg-file.html</link>
		<comments>http://iPhoneDeveloperTips.com/data-file-management/save-uiimage-object-as-a-png-or-jpeg-file.html#comments</comments>
		<pubDate>Thu, 04 Mar 2010 13:38:18 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[Data / File Management]]></category>
		<category><![CDATA[jpeg]]></category>
		<category><![CDATA[jpg]]></category>
		<category><![CDATA[png]]></category>
		<category><![CDATA[save]]></category>
		<category><![CDATA[uiimage]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=5640</guid>
		<description><![CDATA[In an earlier post on saving images from the camera to the Photo Album, a question was posed asking how to save the image to another directory other than the Photo Album. Let&#8217;s walk through one way to write a UIImage object, from the camera or otherwise, as a PNG or JPG file into the [...]]]></description>
			<content:encoded><![CDATA[<p>In an earlier post on <a  href="http://iphonedevelopertips.com/camera/camera-application-to-take-pictures-and-save-images-to-photo-album.html">saving images from the camera to the Photo Album</a>, a question was posed asking how to save the image to another directory other than the Photo Album. Let&#8217;s walk through one way to write a <strong>UIImage</strong> object, from the camera or otherwise, as a PNG or JPG file into the Documents directory.</p>
<h5>Get UIImage Data as PNG or JPEG</h5>
<p><strong>UIKit</strong> includes two C functions, <strong>UIImageJPEGRepresentation</strong> and <strong>UIImagePNGRepresentation</strong> which will return an <strong>NSData</strong> object that represents an image in JPEG or PNG format, respectively. With this information in hand, you can then use the <strong>writeToFile</strong> method of the <strong>NSData</strong> object to write the image data to a specified path.<br />
<span id="more-5640"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">// Create paths to output images</span>
<span style="color: #400080;">NSString</span>  <span style="color: #002200;">*</span>pngPath <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>NSHomeDirectory<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> stringByAppendingPathComponent<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Documents/Test.png&quot;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #400080;">NSString</span>  <span style="color: #002200;">*</span>jpgPath <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>NSHomeDirectory<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> stringByAppendingPathComponent<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Documents/Test.jpg&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// Write a UIImage to JPEG with minimum compression (best quality)</span>
<span style="color: #11740a; font-style: italic;">// The value 'image' must be a UIImage object</span>
<span style="color: #11740a; font-style: italic;">// The value '1.0' represents image compression quality as value from 0.0 to 1.0</span>
<span style="color: #002200;">&#91;</span>UIImageJPEGRepresentation<span style="color: #002200;">&#40;</span>image, <span style="color: #2400d9;">1.0</span><span style="color: #002200;">&#41;</span> writeToFile<span style="color: #002200;">:</span>jpgPath atomically<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// Write image to PNG</span>
<span style="color: #002200;">&#91;</span>UIImagePNGRepresentation<span style="color: #002200;">&#40;</span>image<span style="color: #002200;">&#41;</span> writeToFile<span style="color: #002200;">:</span>pngPath atomically<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// Let's check to see if files were successfully written...</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">// Create file manager</span>
<span style="color: #400080;">NSError</span> <span style="color: #002200;">*</span>error;
<span style="color: #400080;">NSFileManager</span> <span style="color: #002200;">*</span>fileMgr <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSFileManager</span> defaultManager<span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// Point to Document directory</span>
<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>documentsDirectory <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>NSHomeDirectory<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> stringByAppendingPathComponent<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Documents&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// Write out the contents of home directory to console</span>
NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Documents directory: %@&quot;</span>, <span style="color: #002200;">&#91;</span>fileMgr contentsOfDirectoryAtPath<span style="color: #002200;">:</span>documentsDirectory error<span style="color: #002200;">:&amp;</span>error<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;</pre></td></tr></table></div>

<p>Important note, on lines 6 and 9, the value <strong>image</strong> must be a <strong>UIImage</strong> object.</p>
<h5>Source Code</h5>
<p>I&#8217;ve changed the example <a  href="http://iphonedevelopertips.com/camera/camera-application-to-take-pictures-and-save-images-to-photo-album.html">from the original post</a> that wrote a UIImage from the camera to the Photo Album, to write instead to the test files shown above. You can download the source code for the application here: <a href="http://iphonedevelopertips.com/wp-content/uploads/2010/03/camera2.zip">Write UIImage Object as a PNG or JPEG File</a>.</p>
<h5>Simulator Not Supported</h5>
<p>One last note, this application will only run on an actual device as the simulator does not have camera support.</p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/data-file-management/save-uiimage-object-as-a-png-or-jpeg-file.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Validate User Input in UITextField, with Smarts to Properly Manage Copy and Paste</title>
		<link>http://iPhoneDeveloperTips.com/user-interface/validate-user-input-in-uitextfield-with-smarts-to-properly-manage-copy-and-paste.html</link>
		<comments>http://iPhoneDeveloperTips.com/user-interface/validate-user-input-in-uitextfield-with-smarts-to-properly-manage-copy-and-paste.html#comments</comments>
		<pubDate>Mon, 01 Mar 2010 14:54:12 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[User Interface]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=5580</guid>
		<description><![CDATA[I&#8217;ve written a short character validation method that you can use as a starting point for validating characters against a character set. For devices running iPhone OS 3.x and thus support copy/paste, this code will also validate characters pasted into a textfield, and if  invalid characters are found in the buffer, the input is [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve written a short character validation method that you can use as a starting point for validating characters against a character set. For devices running iPhone OS 3.x and thus support copy/paste, this code will also validate characters pasted into a textfield, and if  invalid characters are found in the buffer, the input is not accepted.</p>
<p>The idea is to break apart the incoming string into substrings, using the invalid character set as the characters to split the string. The result returned is an array of objects that have been divided by the invalid characters. If the array has more than one entry, at least one invalid characters was found.<br />
<span id="more-5580"></span></p>
<p>One note, typically the incoming string is just a single character (as typed by the user). However, for cases where the user has pasted a string, the string will vary in length.</p>
<p>If you are a fan of regular expressions you could change up the code using a library such as <a  target="_blank"  href="http://regexkit.sourceforge.net/RegexKitLite/index.html">RegexKitLite</a>.</p>
<p>To use this code, add the method below in the class which is the delegate for the TextField.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">&nbsp;
<span style="color: #11740a; font-style: italic;">// You can add/tailor the acceptable values here...</span>
<span style="color: #6e371a;">#define CHARACTERS          @&quot; ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&quot;</span>
<span style="color: #6e371a;">#define CHARACTERS_NUMBERS  [CHARACTERS stringByAppendingString:@&quot;1234567890&quot;]</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">/*---------------------------------------------------
* Called whenever user enters/deletes character
*--------------------------------------------------*/</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>textField<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITextField <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>textField 
    shouldChangeCharactersInRange<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">NSRange</span><span style="color: #002200;">&#41;</span>range 
    replacementString<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span><span style="color: #a61390;">string</span>
<span style="color: #002200;">&#123;</span>
  <span style="color: #11740a; font-style: italic;">// These are the characters that are ~not~ acceptable</span>
  <span style="color: #400080;">NSCharacterSet</span> <span style="color: #002200;">*</span>unacceptedInput <span style="color: #002200;">=</span>
    <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSCharacterSet</span> characterSetWithCharactersInString<span style="color: #002200;">:</span>CHARACTERS<span style="color: #002200;">&#93;</span> invertedSet<span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Create array of strings from incoming string using the unacceptable</span>
  <span style="color: #11740a; font-style: italic;">// characters as the trigger of where to split the string.</span>
  <span style="color: #11740a; font-style: italic;">// If array has more than one entry, there was at least one unacceptable character</span>
  <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #a61390;">string</span> componentsSeparatedByCharactersInSet<span style="color: #002200;">:</span>unacceptedInput<span style="color: #002200;">&#93;</span> count<span style="color: #002200;">&#93;</span> &gt; <span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span>
    <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
  <span style="color: #a61390;">else</span> 
    <span style="color: #a61390;">return</span> <span style="color: #a61390;">YES</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>You can adjust the character sets as you need to match the input requirements of your application. One more idea would be to manage the character sets inside the method, using a flag to indicate which set to compare against.</p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/user-interface/validate-user-input-in-uitextfield-with-smarts-to-properly-manage-copy-and-paste.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Camera Application to Take Pictures and Save Images to Photo Album</title>
		<link>http://iPhoneDeveloperTips.com/camera/camera-application-to-take-pictures-and-save-images-to-photo-album.html</link>
		<comments>http://iPhoneDeveloperTips.com/camera/camera-application-to-take-pictures-and-save-images-to-photo-album.html#comments</comments>
		<pubDate>Fri, 26 Feb 2010 14:56:59 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[Camera]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=5553</guid>
		<description><![CDATA[Editor&#8217;s Note:If you would like to save the UIImage from the camera to a PNG of JPEG file versus the Photo Album, you can find an example here: Save UIImage Object as a PNG or JPEG File. Also, to email an image from the camera, take a look at this example: How to Send Email [...]]]></description>
			<content:encoded><![CDATA[<p><strong><em>Editor&#8217;s Note:</strong>If you would like to save the UIImage from the camera to a PNG of JPEG file versus the Photo Album, you can find an example here: <a href="http://iphonedevelopertips.com/data-file-management/save-uiimage-object-as-a-png-or-jpeg-file.html">Save UIImage Object as a PNG or JPEG File</a>. Also, to email an image from the camera, take a look at this example: <a href="http://iphonedevelopertips.com/email/how-to-send-email-with-attachments-example-using-iphone-camera-to-email-a-photo.html">How to Send Email with Attachments – Example Using iPhone Camera to Email a Photo</a></em></p>
<p>It&#8217;s surprising easy to create a bare bones camera application on the iPhone. <strong>UIImagePickerController</strong> provides a means to access the camera, take a photo and preview the results. There is also an option to allow resizing and scaling of a photo once captured. Using <strong>UIImageWriteToSavedPhotosAlbum</strong> in the UIKit, you can easily save an image to the Photo Album.</p>
<p>The image on the left in the figure below shows the camera active in the application. The image on the right is the preview option once a photo has been taken.<br />
<span id="more-5553"></span></p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2010/02/photo12.png" /></p>
<h5>Start the Camera</h5>
<p>To work with the camera we begin by creating a <strong>UIImagePickerController</strong> object and setting the <strong>sourceType</strong> to <strong>UIImagePickerControllerSourceTypeCamera</strong>. For this example, I set <strong>allowsImageEditing</strong> to NO to disable editing of photos image. I use presentModalViewController to initiate the display of the camera.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">// Create image picker controller</span>
UIImagePickerController <span style="color: #002200;">*</span>imagePicker <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIImagePickerController alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// Set source to the camera</span>
imagePicker.sourceType <span style="color: #002200;">=</span>  UIImagePickerControllerSourceTypeCamera;
&nbsp;
<span style="color: #11740a; font-style: italic;">// Delegate is self</span>
imagePicker.delegate <span style="color: #002200;">=</span> self;
&nbsp;
<span style="color: #11740a; font-style: italic;">// Allow editing of image ?</span>
imagePicker.allowsImageEditing <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// Show image picker</span>
<span style="color: #002200;">&#91;</span>self presentModalViewController<span style="color: #002200;">:</span>imagePicker animated<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<h5>Save Image to Photo Album</h5>
<p>Once a photo has been taken, the method <strong>didFinishPickingMediaWithInfo</strong> will be called, providing the opportunity to write the image to the Photo Album:</p>

<div class="wp_syntax"><div 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> imagePickerController<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIImagePickerController <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>picker didFinishPickingMediaWithInfo<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSDictionary</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>info
<span style="color: #002200;">&#123;</span>
  <span style="color: #11740a; font-style: italic;">// Access the uncropped image from info dictionary</span>
  UIImage <span style="color: #002200;">*</span>image <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>info objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;UIImagePickerControllerOriginalImage&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Save image</span>
  UIImageWriteToSavedPhotosAlbum<span style="color: #002200;">&#40;</span>image, self, <span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>image<span style="color: #002200;">:</span>didFinishSavingWithError<span style="color: #002200;">:</span>contextInfo<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span>, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span>;
&nbsp;
  <span style="color: #002200;">&#91;</span>picker release<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>Notice the call selector reference above, this selector will be called once the image has been written to the system. For this example I display an alert showing the result of attempting to save the image:</p>

<div class="wp_syntax"><div 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>image<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIImage <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>image didFinishSavingWithError<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSError</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>error contextInfo<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>contextInfo
<span style="color: #002200;">&#123;</span>
  UIAlertView <span style="color: #002200;">*</span>alert;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Unable to save the image  </span>
  <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>error<span style="color: #002200;">&#41;</span>
    alert <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIAlertView alloc<span style="color: #002200;">&#93;</span> initWithTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Error&quot;</span> 
                            message<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Unable to save image to Photo Album.&quot;</span> 
                            delegate<span style="color: #002200;">:</span>self cancelButtonTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Ok&quot;</span> 
                            otherButtonTitles<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
  <span style="color: #a61390;">else</span> <span style="color: #11740a; font-style: italic;">// All is well</span>
    alert <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIAlertView alloc<span style="color: #002200;">&#93;</span> initWithTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Success&quot;</span> 
                            message<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Image saved to Photo Album.&quot;</span> 
                            delegate<span style="color: #002200;">:</span>self cancelButtonTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Ok&quot;</span> 
                            otherButtonTitles<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
  <span style="color: #002200;">&#91;</span>alert show<span style="color: #002200;">&#93;</span>;
  <span style="color: #002200;">&#91;</span>alert release<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<h5>Optional Updates</h5>
<p>This is a good, if not simple, place to start. Here are two additional updates to this application you can tinker with:</p>
<p>#1 &#8211; Check for a camera on device. Refer to this post <a  target="_blank"  href="http://iphonedevelopertips.com/camera/iphone-support-camera-and-recording-video.html">Does iPhone Support Camera</a> to learn more.</p>
<p>#2 &#8211; Set the image editing option to YES. This will require a few additional changes including a request to the information dictionary to return the cropping rectangle that was applied to the original image (see <strong>UIImagePickerControllerCropRect</strong>).</p>
<h5>Source Code</h5>
<p>You can download the source code for the <a href="http://iphonedevelopertips.com/wp-content/uploads/2010/02/camera.zip">camera application here</a>.</p>
<h5>Simulator Not Supported</h5>
<p>One last note, this application will only run on an actual device as the simulator does not have camera support.</p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/camera/camera-application-to-take-pictures-and-save-images-to-photo-album.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Voices That Matter iPhone Developers Conference &#8211; Register to Win a Free Pass!</title>
		<link>http://iPhoneDeveloperTips.com/announcements/voices-that-matter-iphone-developers-conference-register-to-win-a-free-pass.html</link>
		<comments>http://iPhoneDeveloperTips.com/announcements/voices-that-matter-iphone-developers-conference-register-to-win-a-free-pass.html#comments</comments>
		<pubDate>Wed, 24 Feb 2010 19:13:27 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[Announcements]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=5528</guid>
		<description><![CDATA[With the resounding success of the previous Voices That Matter iPhone Developers Conference, once again, Pearson Education and Voices That Matter have put together an impressive list of speakers for their latest event in Seattle, Washington on April 24th and 25th, 2010.
You&#8217;ll have a chance to learn from some of the best in the business, [...]]]></description>
			<content:encoded><![CDATA[<p>With the resounding success of the <a href="http://iphonedevelopertips.com/announcements/voices-that-matter-iphone-developers-conference.html">previous Voices That Matter iPhone Developers Conference</a>, once again, Pearson Education and <a href="http://iphonedevelopertips.com/?wp_ct=25" target="_blank">Voices That Matter</a> have put together an impressive list of speakers for their latest event in Seattle, Washington on April 24th and 25th, 2010.</p>
<p>You&#8217;ll have a chance to learn from some of the best in the business, the scheduled speakers are (listed alphabetically):</p>
<p>* Kevin Avila<br />
* Erik Buck<br />
* Bob Clair<br />
* Joe Conway<br />
* Mike Daley<br />
* Suzanne Ginsburg<br />
* Aaron Hillegass<br />
* Jonathan Rentzsch<br />
* Erica Sadun<br />
* Jeff Sinclair<br />
* August Trometer</p>
<p><a href="http://iphonedevelopertips.com/?wp_ct=25" target="_blank">Voices That Matter</a> is a two-day event and will offer many sessions covering the latest and most intriguing technology in application development for the iPhone and the iPad. A partial list of topics includes:</p>
<p>* Killer User Interfaces for iPhone OS Devices<br />
* Core Animation<br />
* iPhone OS Game Programming<br />
* Audio and OpenAL<br />
* Core Data for the iPhone OS<br />
* Memory Management<br />
* Xcode</p>
<h5>Free Pass Giveaway</h5>
<p>As we did for the conference in October of 2009, Voices That Matter and iPhone Developer Tips are giving away one free pass to the event in Seattle, quite an opportunity as the full admission price is $695 for the two-day event.</p>
<h5>How the Contest Works</h5>
<p>If you are interested to register for the drawing, all you need to do is click the Refer-A-Friend button below and fill in the popup form to refer one or more friends to this blog post. Make sure your email address is correct in the form, as that will be your ticket in the drawing. It’s that simple! I respect your privacy, your email will be used only for registration in the event.</p>
Note: There is an email link embedded within this post, please visit this post to email it.
<h5>The Details</h5>
<p>The deadline to register for the drawing is March 11th, 2010. The winner will be announced on March 12th, 2010. The drawing is for one free admission pass only, you will have to pay any additional travel or related expenses.</p>
<p>Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/announcements/voices-that-matter-iphone-developers-conference-register-to-win-a-free-pass.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Application Icon Name</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/get-application-icon-name.html</link>
		<comments>http://iPhoneDeveloperTips.com/cocoa/get-application-icon-name.html#comments</comments>
		<pubDate>Thu, 18 Feb 2010 03:35:31 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[Cocoa]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=5511</guid>
		<description><![CDATA[In a previous post, Get Application Name, I wrote a line of code to get the application name from the app bundle.
The line of code below is a slight modification that shows how to get the name that will appear on the iPhone below the icon:

&#91;&#91;&#91;NSBundle mainBundle&#93; infoDictionary&#93; objectForKey:@&#34;CFBundleDisplayName&#34;&#93;;

The CFBundleDisplayName value corresponds to the Bundle [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous post, <a  target="_blank"  href="http://iphonedevelopertips.com/cocoa/get-application-name.html">Get Application Name</a>, I wrote a line of code to get the application name from the app bundle.</p>
<p>The line of code below is a slight modification that shows how to get the name that will appear on the iPhone below the icon:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSBundle</span> mainBundle<span style="color: #002200;">&#93;</span> infoDictionary<span style="color: #002200;">&#93;</span> objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;CFBundleDisplayName&quot;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>The <strong>CFBundleDisplayName</strong> value corresponds to the Bundle Display Name in the application plist file, see the figure below:</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2010/02/icon2.png" alt="" title="icon2" width="490" height="239" class="alignnone size-full wp-image-5514" /></p>
<p>You can see the application icon for this example in this figure:</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2010/02/icon3.png" alt="" title="icon3" width="329" height="130" class="alignnone size-full wp-image-5521" /></p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/cocoa/get-application-icon-name.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Read and Write Array, Dictionary and Other Collections to Files</title>
		<link>http://iPhoneDeveloperTips.com/data-file-management/read-and-write-array-dictionary-and-other-collections-to-files.html</link>
		<comments>http://iPhoneDeveloperTips.com/data-file-management/read-and-write-array-dictionary-and-other-collections-to-files.html#comments</comments>
		<pubDate>Mon, 15 Feb 2010 07:26:43 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[Data / File Management]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=5492</guid>
		<description><![CDATA[With just a few lines of code, you can read/write collections to/from files. The code below shows examples for writing and reading back both arrays and dictionaries.
Read and Write Collections to File

NSArray *array = &#91;NSArray arrayWithObjects: 
    @&#34;Hefeweizen&#34;, @&#34;IPA&#34;, @&#34;Pilsner&#34;, @&#34;Stout&#34;, nil&#93;;
&#160;
NSDictionary *dictionary = &#91;NSDictionary dictionaryWithObjectsAndKeys:
  array, @&#34;array&#34;, @&#34;Stout&#34;, @&#34;dark&#34;, @&#34;Hefeweizen&#34;, [...]]]></description>
			<content:encoded><![CDATA[<p>With just a few lines of code, you can read/write collections to/from files. The code below shows examples for writing and reading back both arrays and dictionaries.</p>
<h5>Read and Write Collections to File</h5>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span>array <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> arrayWithObjects<span style="color: #002200;">:</span> 
    <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Hefeweizen&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;IPA&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Pilsner&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Stout&quot;</span>, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #400080;">NSDictionary</span> <span style="color: #002200;">*</span>dictionary <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSDictionary</span> dictionaryWithObjectsAndKeys<span style="color: #002200;">:</span>
  array, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;array&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Stout&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;dark&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Hefeweizen&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;wheat&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;IPA&quot;</span>, 
  <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;hoppy&quot;</span>, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// Get path to documents directory</span>
<span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span>paths <span style="color: #002200;">=</span> NSSearchPathForDirectoriesInDomains<span style="color: #002200;">&#40;</span>NSDocumentDirectory, 
  NSUserDomainMask, <span style="color: #a61390;">YES</span><span style="color: #002200;">&#41;</span>;
<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>paths count<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>
  <span style="color: #11740a; font-style: italic;">// Path to save array data</span>
  <span style="color: #400080;">NSString</span>  <span style="color: #002200;">*</span>arrayPath <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>paths objectAtIndex<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#93;</span> 
      stringByAppendingPathComponent<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;array.out&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Path to save dictionary</span>
  <span style="color: #400080;">NSString</span>  <span style="color: #002200;">*</span>dictPath <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>paths objectAtIndex<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#93;</span> 
      stringByAppendingPathComponent<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;dict.out&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Write array</span>
  <span style="color: #002200;">&#91;</span>array writeToFile<span style="color: #002200;">:</span>arrayPath atomically<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Write dictionary</span>
  <span style="color: #002200;">&#91;</span>dictionary writeToFile<span style="color: #002200;">:</span>dictPath atomically<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Read both back in new collections</span>
  <span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span>arrayFromFile <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> arrayWithContentsOfFile<span style="color: #002200;">:</span>arrayPath<span style="color: #002200;">&#93;</span>;
  <span style="color: #400080;">NSDictionary</span> <span style="color: #002200;">*</span>dictFromFile <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSDictionary</span> dictionaryWithContentsOfFile<span style="color: #002200;">:</span>dictPath<span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>element <span style="color: #a61390;">in</span> arrayFromFile<span style="color: #002200;">&#41;</span> 
    NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Beer: %@&quot;</span>, element<span style="color: #002200;">&#41;</span>;
&nbsp;
  <span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>key <span style="color: #a61390;">in</span> dictFromFile<span style="color: #002200;">&#41;</span> 
    NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;%@ Style: %@&quot;</span>, key, <span style="color: #002200;">&#91;</span>dictionary valueForKey<span style="color: #002200;">:</span>key<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>; 
<span style="color: #002200;">&#125;</span></pre></div></div>

<h5>Verify the Output</h5>
<p>The output in the console window for the above looks as follows:<br />
<img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2010/02/screen.png" alt="" title="screen" width="512" height="227" class="alignnone size-full wp-image-5494" /></p>
]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/data-file-management/read-and-write-array-dictionary-and-other-collections-to-files.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>UIAlertView without Buttons &#8211; Please Wait Dialog</title>
		<link>http://iPhoneDeveloperTips.com/user-interface/uialertview-without-buttons-please-wait-dialog.html</link>
		<comments>http://iPhoneDeveloperTips.com/user-interface/uialertview-without-buttons-please-wait-dialog.html#comments</comments>
		<pubDate>Thu, 11 Feb 2010 12:03:32 +0000</pubDate>
		<dc:creator>John Muchow</dc:creator>
				<category><![CDATA[User Interface]]></category>

		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=5453</guid>
		<description><![CDATA[If you&#8217;ve ever wanted to show a simple &#8220;please wait&#8221; dialog without resorting to a custom view, UIAlertView is a good option, and is even more appropriate if you customize the alert such that no buttons are shown.
In the figure below you can see how a simple alert can be shown (sans buttons) while you [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve ever wanted to show a simple &#8220;please wait&#8221; dialog without resorting to a custom view, <strong>UIAlertView</strong> is a good option, and is even more appropriate if you customize the alert such that no buttons are shown.</p>
<p>In the figure below you can see how a simple alert can be shown (sans buttons) while you are busy doing some other system activity (reading/writing files, etc).</p>
<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2010/02/alert1-206x300.png" alt="" title="alert1" width="206" height="300" class="alignnone size-medium wp-image-5461" /><br />
<span id="more-5453"></span></p>
<h5>UIAlertView without Buttons</h5>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">UIAlertView <span style="color: #002200;">*</span>alert;
&nbsp;
...
&nbsp;
alert <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIAlertView alloc<span style="color: #002200;">&#93;</span> initWithTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Configuring Preferences<span style="color: #2400d9;">\n</span>Please Wait...&quot;</span> 
  message<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> delegate<span style="color: #002200;">:</span>self cancelButtonTitle<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> otherButtonTitles<span style="color: #002200;">:</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #002200;">&#91;</span>alert show<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>Trouble with this approach is that things look a little lopsided, as there is a significant amount of dead space on the bottom where the button(s) are to be shown. We can fix this by adding a few newline characters at the start of our message:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">UIAlertView <span style="color: #002200;">*</span>alert;
&nbsp;
...
&nbsp;
<span style="color: #11740a; font-style: italic;">// Add two newlines characters at the start of the message</span>
alert <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIAlertView alloc<span style="color: #002200;">&#93;</span> initWithTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;<span style="color: #2400d9;">\n</span><span style="color: #2400d9;">\n</span>Configuring Preferences<span style="color: #2400d9;">\n</span>Please Wait...&quot;</span> 
  message<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> delegate<span style="color: #002200;">:</span>self cancelButtonTitle<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> otherButtonTitles<span style="color: #002200;">:</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #002200;">&#91;</span>alert show<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2010/02/alert2-204x300.png" alt="" title="alert2" width="204" height="300" class="alignnone size-medium wp-image-5462" /></p>
<p>The text is nearly centered, yet we&#8217;ve created a different problem, there is now white space on the top <em>and</em> bottom. There is one more approach&#8230;</p>
<h5>UIAlertView with UIActivity Indicator</h5>
<p>In the whitespace on the bottom, let&#8217;s add an activity indicator. Also, remove the newlines in the message text so the text starts near the top:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">UIAlertView <span style="color: #002200;">*</span>alert;
&nbsp;
...
&nbsp;
alert <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIAlertView alloc<span style="color: #002200;">&#93;</span> initWithTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Configuring Preferences<span style="color: #2400d9;">\n</span>Please Wait...&quot;</span> message<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> delegate<span style="color: #002200;">:</span>self cancelButtonTitle<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> otherButtonTitles<span style="color: #002200;">:</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>alert show<span style="color: #002200;">&#93;</span>;
&nbsp;
UIActivityIndicatorView <span style="color: #002200;">*</span>indicator <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIActivityIndicatorView alloc<span style="color: #002200;">&#93;</span> initWithActivityIndicatorStyle<span style="color: #002200;">:</span>UIActivityIndicatorViewStyleWhiteLarge<span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// Adjust the indicator so it is up a few pixels from the bottom of the alert</span>
indicator.center <span style="color: #002200;">=</span> CGPointMake<span style="color: #002200;">&#40;</span>alert.bounds.size.width <span style="color: #002200;">/</span> <span style="color: #2400d9;">2</span>, alert.bounds.size.height <span style="color: #002200;">-</span> <span style="color: #2400d9;">50</span><span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#91;</span>indicator startAnimating<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>alert addSubview<span style="color: #002200;">:</span>indicator<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>indicator release<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p><img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2010/02/alert3-204x300.png" alt="" title="alert3" width="204" height="300" class="alignnone size-medium wp-image-5469" /></p>
<h5>Dismissing the Buttonless UIAlertView</h5>
<p>Since there are no buttons associated with the alert, we have to dismiss the alert ourselves, versus the traditional approach where the system dismisses the alert when a button is pressed.</p>
<p>Here is the call to dismiss the alert:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span>alert dismissWithClickedButtonIndex<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span> animated<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://iPhoneDeveloperTips.com/user-interface/uialertview-without-buttons-please-wait-dialog.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
