<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Sitting Beside Me</title>
	<atom:link href="http://rhbourdeau.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://rhbourdeau.wordpress.com</link>
	<description>Bite-Sized Technical Blurts of an Application Developer</description>
	<lastBuildDate>Sun, 22 Aug 2010 23:27:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='rhbourdeau.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/9b432f663cf64d6bc95ac54e610a95f5?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Sitting Beside Me</title>
		<link>http://rhbourdeau.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://rhbourdeau.wordpress.com/osd.xml" title="Sitting Beside Me" />
	<atom:link rel='hub' href='http://rhbourdeau.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Customizing the labels of a UISwitch</title>
		<link>http://rhbourdeau.wordpress.com/2010/08/22/customizing-the-labels-of-a-uiswitch/</link>
		<comments>http://rhbourdeau.wordpress.com/2010/08/22/customizing-the-labels-of-a-uiswitch/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 22:04:38 +0000</pubDate>
		<dc:creator>rhbourdeau</dc:creator>
				<category><![CDATA[InterfaceBuilder]]></category>
		<category><![CDATA[Objective C]]></category>

		<guid isPermaLink="false">http://rhbourdeau.wordpress.com/?p=90</guid>
		<description><![CDATA[I found a nice little code fragment over at Ars Technica that demonstrates a method for relabelling the two states of a UISwitch, http://arstechnica.com/apple/guides/2009/03/iphone-dev-robust-uiswitch-label-swaps.ars. A UISwitch has two possible states ON and OFF, and those are the labels that you&#8217;re stuck with. For my needs that&#8217;s really disappointing. More often than not, I want YES/NO [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rhbourdeau.wordpress.com&amp;blog=14747606&amp;post=90&amp;subd=rhbourdeau&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I found a nice little code fragment over at Ars Technica that demonstrates a method for relabelling the two states of a <code>UISwitch</code>,<a href="http://arstechnica.com/apple/guides/2009/03/iphone-dev-robust-uiswitch-label-swaps.ars"> http://arstechnica.com/apple/guides/2009/03/iphone-dev-robust-uiswitch-label-swaps.ars</a>. </p>
<p>A <code>UISwitch</code> has two possible states <code>ON</code> and <code>OFF</code>, and those are the labels that you&#8217;re stuck with. For my needs that&#8217;s really disappointing. More often than not, I want <code>YES</code>/<code>NO</code> as responses. </p>
<p>The author of the above referenced article,  Erica Sadun, comes up with what I think is a nice way to solve the problem.   Her method navigates the view hierarchy of a <code>UISwitch</code> until it finds a pair of <code>UILabel</code>s. It then changes the text of these labels. This method might be a little more tolerant of changes to how the switch is implemented, than a solution that just assumes a specific view hierarchy.</p>
<p>Erica creates an Objective C 	<em>category</em> to extend the implementation of the normal <code>UISwitch</code>. </p>
<p>What I don&#8217;t like about her solution is that it doesn&#8217;t allow wimps like me to use her solution with InterfaceBuilder.  Specifically, if you place a <code>UISwitch</code> in your UI via InterfaceBuilder (IB), then you have to let IB allocate and initialize the UI object for you. Erica uses a class method that allocates and inits a new <code>UISwitch</code> object. That&#8217;s cool if you&#8217;re coding your UI from scratch, but I wanted to use this with my existing IB-built interfaces.</p>
<p>I have added to her solution by adding an instance method that modifies an existing <code>UISwitch</code>, relabeling it.</p>
<p>Here&#8217;s the revised header file, which I call <em>UISwitchTagged.h</em>:</p>
<pre><code>
#import &lt;Foundation/Foundation.h&gt;
#import &lt;UIKit/UIKit.h&gt;

@interface UISwitch (tagged)
-(void) setLeftText: (NSString *) tag1 andRight: (NSString *) tag2;
+(UISwitch *)  switchWithLeftText: (NSString *) tag1 andRight: (NSString *) tag2;

@property (nonatomic, readonly)	UILabel *label1;
@property (nonatomic, readonly)	UILabel *label2;
@end
</code></pre>
<p>and the revised implementation file:</p>
<pre>
<code>
#import "UISwitchTagged.h"
#define TAG_OFFSET	900

@implementation UISwitch (tagged)
- (void) spelunkAndTag: (UIView *) aView withCount:(int *) count
{
	for (UIView *subview in [aView subviews])
	{
		if ([subview isKindOfClass:[UILabel class]])
		{
			*count += 1;
			[subview setTag:(TAG_OFFSET + *count)];
		}
		else
			[self spelunkAndTag:subview withCount:count];
	}
}

- (UILabel *) label1
{
	return (UILabel *) [self viewWithTag:TAG_OFFSET + 1];
}

- (UILabel *) label2
{
	return (UILabel *) [self viewWithTag:TAG_OFFSET + 2];
}

+ (UISwitch *) switchWithLeftText: (NSString *) tag1 andRight: (NSString *) tag2
{
	UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectZero];

	int labelCount = 0;
	[switchView spelunkAndTag:switchView withCount:&amp;labelCount];

	if (labelCount == 2)
	{
		[switchView.label1 setText:tag1];
		[switchView.label2 setText:tag2];
	}

	return [switchView autorelease];
}

// My additional instance method. I keep the code structure the same.

- (void) setLeftText: (NSString *) tag1 andRight: (NSString *) tag2
{
	int labelCount = 0;
	[self spelunkAndTag:self withCount:&amp;labelCount];

	if (labelCount == 2)
	{
		[self.label1 setText:tag1];
		[self.label2 setText:tag2];
	}
}
@end
</code>
</pre>
<p>To use my version, suppose you have view controller class with a pluggable outlet as follows:</p>
<pre>
<code>
@interface someViewController : UIViewController {
	IBOutlet UISwitch		*swt_mySwitch;
}
@end
</code>
</pre>
<p>You connect the <code>swt_mySwitch</code> outlet to the <code>UISwitch</code> object in your interface as per usual. But in the implementation file you do something like the following:</p>
<pre><code>
@implementation someViewController
- (void)viewDidLoad {
    [super viewDidLoad];

   // override labels on switch
   [swt_mySwitch setLeftText:@"Yes" andRight:@"No"];
}
</code>
</pre>
<p>and you will now see the labels <code>Yes</code> and <code>No</code> instead of <code>On</code> and <code>Off</code>.</p>
<p>Thanks Erica.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rhbourdeau.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rhbourdeau.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rhbourdeau.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rhbourdeau.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rhbourdeau.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rhbourdeau.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rhbourdeau.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rhbourdeau.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rhbourdeau.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rhbourdeau.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rhbourdeau.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rhbourdeau.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rhbourdeau.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rhbourdeau.wordpress.com/90/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rhbourdeau.wordpress.com&amp;blog=14747606&amp;post=90&amp;subd=rhbourdeau&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rhbourdeau.wordpress.com/2010/08/22/customizing-the-labels-of-a-uiswitch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/feac57209c1dd61ab74f0a5c9c9aff9d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rhbourdeau</media:title>
		</media:content>
	</item>
		<item>
		<title>IB objects don&#8217;t exist until the view appears</title>
		<link>http://rhbourdeau.wordpress.com/2010/08/18/ib-objects-dont-exist-until-the-view-appears/</link>
		<comments>http://rhbourdeau.wordpress.com/2010/08/18/ib-objects-dont-exist-until-the-view-appears/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 16:23:55 +0000</pubDate>
		<dc:creator>rhbourdeau</dc:creator>
				<category><![CDATA[InterfaceBuilder]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Objective C]]></category>

		<guid isPermaLink="false">http://rhbourdeau.wordpress.com/?p=85</guid>
		<description><![CDATA[When using Interface Builder, it is easy to overlook the order in which the visual objects of the interface are allocated, since you don't see that code. In this little post, I show the mistake and how I corrected the problem.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rhbourdeau.wordpress.com&amp;blog=14747606&amp;post=85&amp;subd=rhbourdeau&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I made a silly mistake that took me a couple of days to track down. I have a simple interface that just displays an image (like displaying an email attachment) that was created by some other part of the system. I created a view controller to handle the simple task of loading the image using my little interface. But I was encountering a different types of errors, ABRT and BAD_ACCESS,  typical indicators of flawed memory allocation/deallocation logic.</p>
<p>This is the cost of using tools that generate code for you that you can never see. It takes a long time to understand the subtleties of the behavior of the code generated.</p>
<p>In this case, I am talking about the Mac InterfaceBuilder (IB). Yes, I know that I will need to ween myself away from IB at some point, but it serves its purpose for now. I created a <code>UIViewController</code> subclass called <code>ShowImageCtl</code>.</p>
<p>Originally the code looked like this (well this is the relevant portion):</p>
<pre><code>
@interface ShowImageCtl: UIViewController
{
   IBOutlet UIImageView *imgView;
}
-(ShowImageCtl*) initWithThisImage: (UIImage*) img;
@property (nonatomic,retain) IBOutlet UIImageView* imgView;
@end

@implementation ShowImageCtl
@synthesize imgView;

-(ShowImageCtl*) initWithThisImage: (UIImage*) img
{
	imgView.image = img;  // this line throws an exception
	return (self);
}
@end
</code></pre>
<p>I used IB to create the visual layout of the view. It includes a <code>UIImageView</code> object within the view. I connected the <code>UIImageView</code> in my InterfaceBuilder interface to the outlet above named <code>imgView</code>. Everything should work find, right?</p>
<p>I would load the view as follows:</p>
<pre><code>
UIImage *img = ..... // I fetch my image here
ShowImageCtl *imgCtl = [[ShowImageCtl alloc] initWithThisImage:img];
[self presentModalViewController:imgCtl animated:YES];
[imgCtl release];
[img release];
</code></pre>
<p>An exception was being thrown upon creating the <code>imgCtl</code>, and I traced it to the  line noted in the <code>ShowImageCtl</code> implementation code above.  Using the debugger it was easy to see that <code>imgView</code> was a null pointer, it had not yet been initialized. But that was the job of the code generated by the IB, not me!</p>
<p>I am sure I could find this documented somewhere, but the docs are thin on details like this. What appears to be happening is that the interface objects created by the IB code, such as the <code>UIImageView</code> object that I connected to <code>imgView</code>, are not created at the time I allocate the view controller. But these objects <strong>have</strong> been allocated by the time the view is displayed (duh). Since every view controller can receive <code>viewDidLoad</code>  messages, I made the following changes to my <code>ShowImageCtl</code> code:</p>
<pre><code>
@interface ShowImage : UIViewController {
	IBOutlet UIImageView *imgView;
	UIImage *imageToDisplay;         // this instance variable holds reference to image until needed
}
-(ShowImage*) initWithThisImage: (UIImage*) img;

@property (nonatomic,retain) IBOutlet UIImageView* imgView;
@end

@implementation ShowImage
@synthesize imgView;

 // when this method is invoked, the imgView object is already allocated
- (void)viewDidLoad
{
    [super viewDidLoad];
    imgView.image = imageToDisplay;
}	

// Now we just hold the reference to the image and assign it to the
// interface object later
-(ShowImage*) initWithThisImage: (UIImage*) img
{
	imageToDisplay = img;  // have to wait to initialize view image until after it is loaded
	return (self);
}
 @end
</code></pre>
<p>Now everything works as expected. Whew.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rhbourdeau.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rhbourdeau.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rhbourdeau.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rhbourdeau.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rhbourdeau.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rhbourdeau.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rhbourdeau.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rhbourdeau.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rhbourdeau.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rhbourdeau.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rhbourdeau.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rhbourdeau.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rhbourdeau.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rhbourdeau.wordpress.com/85/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rhbourdeau.wordpress.com&amp;blog=14747606&amp;post=85&amp;subd=rhbourdeau&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rhbourdeau.wordpress.com/2010/08/18/ib-objects-dont-exist-until-the-view-appears/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/feac57209c1dd61ab74f0a5c9c9aff9d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rhbourdeau</media:title>
		</media:content>
	</item>
		<item>
		<title>Having build problems with iPhone location services?</title>
		<link>http://rhbourdeau.wordpress.com/2010/08/13/having-build-problems-with-iphone-location-services/</link>
		<comments>http://rhbourdeau.wordpress.com/2010/08/13/having-build-problems-with-iphone-location-services/#comments</comments>
		<pubDate>Fri, 13 Aug 2010 22:40:59 +0000</pubDate>
		<dc:creator>rhbourdeau</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://rhbourdeau.wordpress.com/?p=76</guid>
		<description><![CDATA[This just happens to be the first time that I really needed to add a framework to my project, so my problem really has nothing to do with location services, and has everything to do with how you add in a framework. I am guessing that many folks out there also add location services as their first framework as well, but the lesson is the same. In this little blurb, I show the steps for adding a new framework without creating a platform-specific configuration. <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rhbourdeau.wordpress.com&amp;blog=14747606&amp;post=76&amp;subd=rhbourdeau&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am now adding location services to my iPhone app. For whatever reason, Xcode won&#8217;t build my app when adding a reference to <code>&lt;CoreLocation/CoreLocation.h&gt;</code></p>
<p>Linking problems, object not found, etc.</p>
<p>Location Services, which provide the controls needed to activate and monitor the GPS services of the iPhone, are part of a framework called <code>CoreLocation.framework</code>.</p>
<p>Now this just happens to be the first time that I really needed to add a framework to my project, so it really has nothing to do with location services, and has everything to do with how you add in a framework. But I am guessing that many folks out there also add location services as their first framework as well.</p>
<p>I found the framework, actually the two versions of the framework hiding in my filesystem. There&#8217;s a version, of course, for the iPhoneSimulator, and a version for the actual physical iPhone device.  These two frameworks are found here:</p>
<div id="_mcePaste">Device:</div>
<div id="_mcePaste" style="padding-left:30px;"><code>/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk/System/Library/Frameworks/CoreLocation.framework</code></div>
<div id="_mcePaste">Simulator:</div>
<div id="_mcePaste" style="padding-left:30px;"><code>/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/System/Library/Frameworks/CoreLocation.framework</code></div>
<p>Now I can expose my persistent ignorance about effective configuration management with XCode. The only difference in pathnames for these two framework versions is right near the beginning,  <code>iPhoneOS.platform</code>, and <code>iPhoneSimulator.platform</code>. I can see that Xcode figures this out for other frameworks, like <code>UIKit.framework</code>,  <code>Foundation.framework</code>, and  <code>CoreGraphics.framework</code>.</p>
<p>I was able to add the <code>CoreLocation</code> frameworks one at a time to my project, and things would work so long as I only built for the same platform framework that i added to the project. So if I added the iPhoneSimulator.platform version, I could build for the simulator.  At least I could build. So how are those other frameworks, <code>UIKit</code>, and so on, added in into my project without needing to be platform specific?</p>
<p>So I selected one of those frameworks from the browser pane, brought up the context menu, and chose <em>GetInfo</em> . The following information is displayed:</p>
<p><a href="http://rhbourdeau.files.wordpress.com/2010/08/frameworkconfig.jpg"><img class="alignnone size-full wp-image-80" title="frameworkconfig" src="http://rhbourdeau.files.wordpress.com/2010/08/frameworkconfig.jpg?w=500&#038;h=512" alt="" width="500" height="512" /></a></p>
<p>Now notice the value shown for <em>Path</em> (not Fullpath). It&#8217;s a <span style="text-decoration:underline;">relative</span> path that begins below the platform-specific parts of the actual path. To add, a such a relative reference to a framework, we proceed as follows.</p>
<p>First, choose <em>Project | Add to Project</em> form the Xcode menu.</p>
<p><a href="http://rhbourdeau.files.wordpress.com/2010/08/frameworksconfig-projectadd.gif"><img class="alignnone size-full wp-image-81" title="frameworksconfig-projectadd" src="http://rhbourdeau.files.wordpress.com/2010/08/frameworksconfig-projectadd.gif?w=385&#038;h=511" alt="" width="385" height="511" /></a></p>
<p>You will have to use a Finder-type of tool to navigate the file system to your framework. Find the iPhoneSimulator version and add it (or the iPhoneOS version, does not matter).  You&#8217;ll see something like the following window displayed:</p>
<p><a href="http://rhbourdeau.files.wordpress.com/2010/08/frameworkconfig-adddialog.gif"><img class="alignnone size-full wp-image-78" title="frameworkconfig-adddialog" src="http://rhbourdeau.files.wordpress.com/2010/08/frameworkconfig-adddialog.gif?w=404&#038;h=377" alt="" width="404" height="377" /></a></p>
<p>Ok, here&#8217;s the important step. Make sure that you have unchecked &#8220;<em>Copy items into destination group&#8217;s folder.</em>&#8221; Also make sure that you have checked &#8220;<em>Create folder references for any added folders.</em>&#8221;  Then choose <em>Add</em>.</p>
<p>We&#8217;re done.</p>
<p>You&#8217;ll see something like the following:</p>
<p><a href="http://rhbourdeau.files.wordpress.com/2010/08/frameworkconfig-alldone.gif"><img class="alignnone size-full wp-image-79" title="frameworkconfig-alldone" src="http://rhbourdeau.files.wordpress.com/2010/08/frameworkconfig-alldone.gif?w=305&#038;h=389" alt="" width="305" height="389" /></a></p>
<p>Now just so that you notice, take a look at the icon shown for each of the Frameworks that are in your project. See that little white bubble at the lower left of the suitcase icon?  That indicates that the Framework is added as a relative reference to the project, as opposed to having the entire framework literally copied into the project folder.</p>
<p>All is now well in the world. I can happily continue my development with location services. My friday night should be lovely!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rhbourdeau.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rhbourdeau.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rhbourdeau.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rhbourdeau.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rhbourdeau.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rhbourdeau.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rhbourdeau.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rhbourdeau.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rhbourdeau.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rhbourdeau.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rhbourdeau.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rhbourdeau.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rhbourdeau.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rhbourdeau.wordpress.com/76/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rhbourdeau.wordpress.com&amp;blog=14747606&amp;post=76&amp;subd=rhbourdeau&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rhbourdeau.wordpress.com/2010/08/13/having-build-problems-with-iphone-location-services/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/feac57209c1dd61ab74f0a5c9c9aff9d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rhbourdeau</media:title>
		</media:content>

		<media:content url="http://rhbourdeau.files.wordpress.com/2010/08/frameworkconfig.jpg" medium="image">
			<media:title type="html">frameworkconfig</media:title>
		</media:content>

		<media:content url="http://rhbourdeau.files.wordpress.com/2010/08/frameworksconfig-projectadd.gif" medium="image">
			<media:title type="html">frameworksconfig-projectadd</media:title>
		</media:content>

		<media:content url="http://rhbourdeau.files.wordpress.com/2010/08/frameworkconfig-adddialog.gif" medium="image">
			<media:title type="html">frameworkconfig-adddialog</media:title>
		</media:content>

		<media:content url="http://rhbourdeau.files.wordpress.com/2010/08/frameworkconfig-alldone.gif" medium="image">
			<media:title type="html">frameworkconfig-alldone</media:title>
		</media:content>
	</item>
		<item>
		<title>XCode Build Error caused by Xcode&#8217;s file management</title>
		<link>http://rhbourdeau.wordpress.com/2010/08/05/xcode-build-error-caused-by-xcodes-file-management/</link>
		<comments>http://rhbourdeau.wordpress.com/2010/08/05/xcode-build-error-caused-by-xcodes-file-management/#comments</comments>
		<pubDate>Fri, 06 Aug 2010 01:34:46 +0000</pubDate>
		<dc:creator>rhbourdeau</dc:creator>
				<category><![CDATA[Helpful Technical Tips]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://rhbourdeau.wordpress.com/?p=66</guid>
		<description><![CDATA[I should have dug deeper sooner than I did. It took me several hours to find the source of a mind-boggling compile-time problem. It goes like this. I have a View Controller subclass called HomeClaimForm1. There are, of course, two files involved here: HomeClaimForm1.h HomeClaimForm1.m Life was good. The class was evolving, since I am [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rhbourdeau.wordpress.com&amp;blog=14747606&amp;post=66&amp;subd=rhbourdeau&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I should have dug deeper sooner than I did. It took me several hours to find the source of a mind-boggling compile-time problem. It goes like this.</p>
<p>I have a View Controller subclass called <code>HomeClaimForm1</code>. There are, of course, two files involved here:</p>
<ul>
<li><code>HomeClaimForm1.h</code></li>
<li><code>HomeClaimForm1.m</code></li>
</ul>
<p>Life was good. The class was evolving, since I am really doing prototyping as I learn the iPhone platform.  Then, one day, I add a new instance variable to the <code>.h</code> file. Something like this:</p>
<pre><code>@interface HomeClaimForm1 : UIViewController
{
    ......
    IBOutlet	UITextField	*repNameTxt;
    .....
}
</code></pre>
<p>I also make this instance variable a property:</p>
<pre><code>     @property (nonatomic,retain) IBOutlet UITextField	repNameTxt;
</code></pre>
<p>I add code in the <code>.m</code> file to <em>synthesize</em> the property:</p>
<pre><code>     ......
     @implementation HomeClaimForm1
     @synthesize .....,repNameTxt;
     ......
</code></pre>
<p>I build, and <strong>an error is generated</strong> that I cannot track down for many hours.</p>
<p style="padding-left:30px;"><strong><code>error: no declaration of property 'repNameTxt' found in the interface</code></strong></p>
<p>I assumed that this was caused by some strange syntax error that was preventing the declaration in the <code>.h</code> file from being recognized, but no such errors were flagged and no amount of code rewriting would change this fact. In fact, it seemed that all changes made to the <code>.h</code> file were suddenly not being recognized by the <code>.m</code> file. If I caused a syntax error in the <code>.h</code> file, that would be flagged by the compiler. I even deleted the contents of the <code>.h</code> file and did a build, and the compiler didn&#8217;t see any problem at all with my <code>.m</code>, except for that silly error shown above.</p>
<p>Conclusion- the <code>.h</code> and <code>.m</code> files were both being compiled, but the <code>.m</code> file could not possibly be importing the <code>.h</code> file that I was editing. Somehow Xcode had cached a bogus copy of the <code>.h</code> file somewhere. But how could this be possible?</p>
<p>Yes. How&#8230;&#8230;</p>
<p>My simple project name is <code>abaccess</code> and it is located in <code>~/Documents/abaccess</code>. By switching to the Unix terminal app, I started browsing the project directory. I found a <code>Classes</code> subdirectory. Strangely it appears that my <code>.h</code> and <code>.m</code> files are arbitrarily scattered between the project root <code>~/Documents/abaccess</code> and <code>~/Documents/abaccess/Classes</code> (regardless of the fact that in my XCode project, all <code>.h</code> and <code>.m</code> files are located in the Xcode Classes grouping). What was interesting is this:<br />
<a href="http://rhbourdeau.files.wordpress.com/2010/08/grab-listing1.gif"><img class="alignnone size-full wp-image-67" title="grab-listing1" src="http://rhbourdeau.files.wordpress.com/2010/08/grab-listing1.gif?w=700" alt="" /></a></p>
<p>Do you see it? There are two copies of <code>HomeClaimForm1.h</code>. One in <code>Classes</code> and one in the project root. The one at the project root is dated July 11 where the copy in <code>Classes</code> is dated August 5.</p>
<p>I <code>rm</code>&#8216;d the July 11 copy. Did a rebuild, an magically, all my errors disappeared.</p>
<p>I have had to do remove the build subdirectory before, have had to clean all targets to get a fresh compile, but never have I see this bizarre behavior.</p>
<p>Annoying but a lesson learned, again.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rhbourdeau.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rhbourdeau.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rhbourdeau.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rhbourdeau.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rhbourdeau.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rhbourdeau.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rhbourdeau.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rhbourdeau.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rhbourdeau.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rhbourdeau.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rhbourdeau.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rhbourdeau.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rhbourdeau.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rhbourdeau.wordpress.com/66/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rhbourdeau.wordpress.com&amp;blog=14747606&amp;post=66&amp;subd=rhbourdeau&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rhbourdeau.wordpress.com/2010/08/05/xcode-build-error-caused-by-xcodes-file-management/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/feac57209c1dd61ab74f0a5c9c9aff9d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rhbourdeau</media:title>
		</media:content>

		<media:content url="http://rhbourdeau.files.wordpress.com/2010/08/grab-listing1.gif" medium="image">
			<media:title type="html">grab-listing1</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating a singleton object in Objective C</title>
		<link>http://rhbourdeau.wordpress.com/2010/08/03/creating-a-singleton-object-in-objective-c/</link>
		<comments>http://rhbourdeau.wordpress.com/2010/08/03/creating-a-singleton-object-in-objective-c/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 03:47:07 +0000</pubDate>
		<dc:creator>rhbourdeau</dc:creator>
				<category><![CDATA[Objective C]]></category>

		<guid isPermaLink="false">http://rhbourdeau.wordpress.com/?p=60</guid>
		<description><![CDATA[A singleton class/object is like a global variable. My need for such a class is as a container for storing the various user preferences from my iPhone app. I didn&#8217;t want to have to figure out a way to constantly pass this object around to provide access to it. Instead, I just wanted to be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rhbourdeau.wordpress.com&amp;blog=14747606&amp;post=60&amp;subd=rhbourdeau&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A singleton class/object is like a global variable. My need for such a class is as a container for storing the various user preferences from my iPhone app. I didn&#8217;t want to have to figure out a way to constantly pass this object around to provide access to it. Instead, I just wanted to be able to reach out, obtain a reference to this global object, and obtain information from it.</p>
<p>My final result uses syntax like these:</p>
<pre><code>NSString *userEmail = [[MyPreferences sharedInstance] userEmailPreference];</code></pre>
<pre><code>NSString *userAddress = [[MyPreferences sharedInstance] userAddressPreference];</code></pre>
<pre><code>NSString *userId = [[MyPreferences sharedInstance] userIdPreference];</code></pre>
<p>The fragment<code>[MyPreferences sharedInstance]</code> creates and/or obtains a reference to my singleton object that stores all the user preference settings.  I then send it a message <code>userEmailPreference</code>, <code>userAddressPreference</code>, or <code>userId</code> to get the value of interest.</p>
<p>No need for me to explain how to do this. <a href="http://www.duckrowing.com/2010/05/21/using-the-singleton-pattern-in-objective-c/">Fred McCann did an excellent job</a>, providing safeguards to implementation code that ensure the Singleton is persistent, unique, and threadsafe. Warning, I tried suggestions from a few other authors, but these were problematic. Fred was thorough and helpful.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rhbourdeau.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rhbourdeau.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rhbourdeau.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rhbourdeau.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rhbourdeau.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rhbourdeau.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rhbourdeau.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rhbourdeau.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rhbourdeau.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rhbourdeau.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rhbourdeau.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rhbourdeau.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rhbourdeau.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rhbourdeau.wordpress.com/60/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rhbourdeau.wordpress.com&amp;blog=14747606&amp;post=60&amp;subd=rhbourdeau&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rhbourdeau.wordpress.com/2010/08/03/creating-a-singleton-object-in-objective-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/feac57209c1dd61ab74f0a5c9c9aff9d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rhbourdeau</media:title>
		</media:content>
	</item>
		<item>
		<title>Pulling apart an NSDate object</title>
		<link>http://rhbourdeau.wordpress.com/2010/08/03/39/</link>
		<comments>http://rhbourdeau.wordpress.com/2010/08/03/39/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 04:31:43 +0000</pubDate>
		<dc:creator>rhbourdeau</dc:creator>
				<category><![CDATA[Helpful Technical Tips]]></category>
		<category><![CDATA[Objective C]]></category>

		<guid isPermaLink="false">http://rhbourdeau.wordpress.com/?p=39</guid>
		<description><![CDATA[It is funny how some seemingly simple and common programming problems are just not simple. Such is the case with date and time manipulation. The reality of date and time manipulation is that there are a huge number of variations to what we want done, and that is complicated by the fact that dates and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rhbourdeau.wordpress.com&amp;blog=14747606&amp;post=39&amp;subd=rhbourdeau&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It is funny how some seemingly simple and common programming problems are just not simple. Such is the case with date and time manipulation. The reality of date and time manipulation is that there are a huge number of variations to what we want done, and that is complicated by the fact that dates and times really are unexpectedly complex objects.</p>
<p>Rather than be philosophical, here&#8217;s my problem. A little segment of my iPhone app needs to alert the user if they attempt to dial our office on a date or time when the office is closed. We are open M-F from 8AM to 4:30PM Eastern Daylight Time (or standard time, depending on the date). Of course, the reality is that we are also sometimes closed due to holidays, and we might like to offer extended hours during certain holiday seasons. This latter situation means that my app needs to obtain office hours dynamically to do a <em>good job</em> at alerting the user. But let&#8217;s keep it simple for now.</p>
<p>Here&#8217;s some simple Objective-C code that does my calculation. Apologies for the formatting. I am new to WordPress and it is not friendly displaying code.</p>
<div style="background-color:#ffffcc;">
<pre><code>
-(BOOL)officeIsOpen
{
     //
     // Get current date and time
     //
     NSDate *now = [[NSDate alloc] init];
     NSTimeZone *timeZoneEDT =
             [NSTimeZone  timeZoneWithName:@"EDT"];
     NSCalendar *gregorian =
             [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
     [gregorian setTimeZone:timeZoneEDT];

     //
     // Use time-zone adjusted calendar object to extract the
     // data/time components we need to determine office hours
     //
     NSDateComponents *weekdayComponents = 
             [gregorian  components: NSWeekdayCalendarUnit fromDate: now];
     NSDateComponents *hourComponents =
             [gregorian  components: NSHourCalendarUnit fromDate: now];
     NSDateComponents *minComponents =
             [gregorian  components: NSMinuteCalendarUnit fromDate: now];

     NSInteger weekday = [weekdayComponents weekday];	// 1 = Sunday
     NSInteger hour    = [hourComponents hour];		// 24 hour clock
     NSInteger min     = [minComponents minute];

     //
     // Very crude static hours check
     //
     BOOL isOpen = NO;
     if ( (weekday &gt;1 &amp;&amp; weekday &lt; 7 )   // M-F
          &amp;&amp;  (hour &gt;= 8 )                          // open at 8AM
          &amp;&amp;  (hour &lt;= 16 )                         // close at 4:30
          &amp;&amp;  (hour &lt; 16 || min &lt;= 30 ))	   // close at 4:30
     {
          isOpen = YES;
     }

     //
     // clean up
     //
     [gregorian release];
     [now release];

     return (isOpen);
}
</code></pre>
</div>
<p>It looks a little cumbersome at first glance, but many of the solutions I found involved using the <code>NSDateFormatter</code> class to extract components like day of week, hours, and minutes from an <code>NSDate</code>. That&#8217;s just plain nasty and distasteful. The solution that Apple has offered here is pretty nice.</p>
<ol>
<li>We get today&#8217;s date &amp; time.</li>
<li>We create a calendar that will be used as a context for interpreting the date and time.</li>
<li>We extract the relevant components from date &amp; time object using the calendar a context.</li>
</ol>
<p>The date &amp; time manipulation services in Objective C are very rich. I am not even scratching the surface here. But this little example might be something others can use readily if they have my exact same problem.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rhbourdeau.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rhbourdeau.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rhbourdeau.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rhbourdeau.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rhbourdeau.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rhbourdeau.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rhbourdeau.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rhbourdeau.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rhbourdeau.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rhbourdeau.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rhbourdeau.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rhbourdeau.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rhbourdeau.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rhbourdeau.wordpress.com/39/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rhbourdeau.wordpress.com&amp;blog=14747606&amp;post=39&amp;subd=rhbourdeau&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rhbourdeau.wordpress.com/2010/08/03/39/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/feac57209c1dd61ab74f0a5c9c9aff9d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rhbourdeau</media:title>
		</media:content>
	</item>
		<item>
		<title>Mysterious parsing errors with libxml2</title>
		<link>http://rhbourdeau.wordpress.com/2010/08/01/mysterious-parsing-errors-with-libxml2/</link>
		<comments>http://rhbourdeau.wordpress.com/2010/08/01/mysterious-parsing-errors-with-libxml2/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 16:03:42 +0000</pubDate>
		<dc:creator>rhbourdeau</dc:creator>
				<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://rhbourdeau.wordpress.com/?p=35</guid>
		<description><![CDATA[Libxml2 fails when it encounters  default namespace declarations in an XML document. Learn to recognize the problem so you don't waste too much time trying to figure out what is wrong with either the document or your code.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rhbourdeau.wordpress.com&amp;blog=14747606&amp;post=35&amp;subd=rhbourdeau&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I really appreciate the libxml2 library (<a href="http://www.xmlsoft.org/index.html">http://www.xmlsoft.org/index.html</a>). It&#8217;s highly portable, provides lots of nice tools for creating and manipulating xml, works on the iPhone, etc. But there is one really annoying problem with the library that occurs when you have an XML document that uses xmlns like this:</p>
<p style="padding-left:30px;"><code> &lt;person xmlns="http://host.domain/mynamespace"&gt;<br />
&lt;name&gt;Harry Handwasher&lt;/name&gt;<br />
&lt;city&gt;Smalltown&lt;/city&gt;<br />
&lt;/person&gt;<br />
</code></p>
<p>Here, the tags <code>person</code>, <code>name</code>, and <code>city</code> are supposed to be assumed part of the default namespace <code>http://host.domain/mynamespace</code>.  This is completely legal syntax, very compact and clean, and desired (see W3 examples here: <a href="http://www.w3schools.com/xml/xml_namespaces.asp">http://www.w3schools.com/xml/xml_namespaces.asp</a></p>
<p>However, libxml2 will not parse this document and will generate an parse error. You have but two choices, from what I can tell, to correct it:</p>
<ol>
<li>You can delete the name space declaration from you code completely</li>
<li>You can give a prefix name to the namespace and then use that prefix with all tags.</li>
</ol>
<p>So in the first case, I would modify my xml document to look like this instead:</p>
<p style="padding-left:30px;"><code> &lt;person&gt;<br />
&lt;name&gt;Harry Handwasher&lt;/name&gt;<br />
&lt;city&gt;Smalltown&lt;/city&gt;<br />
&lt;/person&gt;<br />
</code></p>
<p>and in the second case, I would modify my xml document to look like this:</p>
<p style="padding-left:30px;"><code> &lt;bob:person xmlns:bob="http://host.domain/mynamespace"&gt;<br />
&lt;bob:name&gt;Harry Handwasher&lt;/bob:name&gt;<br />
&lt;bob:city&gt;Smalltown&lt;/bob:city&gt;<br />
&lt;/bob:person&gt;</code></p>
<p>Neither of these options will work in all situations. In particular, what can you do if you are reading an XML file that you did not create? If you encounter a parsing error, you&#8217;re stuck. You could prescan the document before parsing and check for the use of a default namespace. If found, you could just delete the namespace declaration and thus avoid the parsing error. This latter method is unsavory, but it might work.</p>
<p>I might dig a little deeper to see if the libxml2 parser can be controlled to not automatically abort on such errors.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rhbourdeau.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rhbourdeau.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rhbourdeau.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rhbourdeau.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rhbourdeau.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rhbourdeau.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rhbourdeau.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rhbourdeau.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rhbourdeau.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rhbourdeau.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rhbourdeau.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rhbourdeau.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rhbourdeau.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rhbourdeau.wordpress.com/35/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rhbourdeau.wordpress.com&amp;blog=14747606&amp;post=35&amp;subd=rhbourdeau&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rhbourdeau.wordpress.com/2010/08/01/mysterious-parsing-errors-with-libxml2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/feac57209c1dd61ab74f0a5c9c9aff9d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rhbourdeau</media:title>
		</media:content>
	</item>
		<item>
		<title>Preserving CDATA sections with XSL transformations</title>
		<link>http://rhbourdeau.wordpress.com/2010/07/30/preserving-cdata-sections-with-xsl-transformations/</link>
		<comments>http://rhbourdeau.wordpress.com/2010/07/30/preserving-cdata-sections-with-xsl-transformations/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 04:16:19 +0000</pubDate>
		<dc:creator>rhbourdeau</dc:creator>
				<category><![CDATA[XML]]></category>
		<category><![CDATA[XSLT]]></category>

		<guid isPermaLink="false">http://rhbourdeau.wordpress.com/?p=32</guid>
		<description><![CDATA[Learn a technique to copy a CDATA section from an input XML document to an output XML document using XSLT. Useful for building RSS and ATOM feed aggregators.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rhbourdeau.wordpress.com&amp;blog=14747606&amp;post=32&amp;subd=rhbourdeau&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I mentioned in my previous post that I was building an RSS/ATOM feed aggregator. That basically means that I have a program that reads RSS and ATOM files from other sites via HTTP, and integrates them together into a new, combined ATOM file. RSS and ATOM documents are both XML. So I am taking one or more XML documents, applying XSLT to these input files, and outputting another XML file.</p>
<p>Since I am outputting XML files, I do have to concern myself with the fact that when I read the RSS and ATOM files in to my program, they are parsed, and CDATA sections are internalized.</p>
<p>For example, suppose that I have an XML input fragment that looks like this:</p>
<p style="padding-left:30px;"><code>&lt;description&gt;<br />
&lt;![CDATA[What a wonderful, wonderful world]]&gt;<br />
&lt;/description&gt;<br />
</code></p>
<p>What I might want to do in my transformation is change the name of the tag from description to summary. It would be convenient if I could do it with XSLT code like this:</p>
<p style="padding-left:30px;"><code> &lt;summary&gt;&lt;xsl:value-of select="description"/&gt;&lt;/summary&gt;<br />
</code></p>
<p>But if I do that, the output would come out as follows:</p>
<p style="padding-left:30px;"><code> &lt;summary&gt;What a wonderful, wonderful world&lt;/summary&gt;<br />
</code></p>
<p>when what I really want is this:</p>
<p style="padding-left:30px;"><code> &lt;summary&gt;&lt;![CDATA[What a wonderful, wonderful world]]&gt;&lt;/summary&gt;</code></p>
<p>I tried many different means of achieving this, and finally stumbled into what I now consider my best known solution:</p>
<p style="padding-left:30px;"><code> &lt;summary&gt;<br />
&lt;xsl:text disable-output-escaping="yes"&gt;&amp;lt;![CDATA[&lt;/xsl:text&gt;<br />
&lt;xsl:value-of select="description" disable-output-escaping="yes"/&gt;<br />
&lt;xsl:text disable-output-escaping="yes"&gt;]]&amp;gt;&lt;/xsl:text&gt;<br />
&lt;/summary&gt;</code></p>
<p>A brief explanation in case this doesn&#8217;t settle right with you. First, a CDATA section tells XSL (and any XML parser) to stop parsing everything it finds in the CDATA section. Treat the contents of CDATA as a blob and just output it as is. Well, that would be fine if I didn&#8217;t want XSL to insert a value into the contents of the CDATA section, namely the contents of the &lt;description&gt; element. So, it was necessary to prevent XSL from even seeing that I was building a CDATA section.</p>
<p>The &lt;xsl:text&gt; instruction tells the process to just blurt out the enclosed content, just like it would if it encountered a CDATA section. Our content here is the beginning of the code for a CDATA section.</p>
<p>Next, it is important to note that the &#8216;&lt;&#8217; and &#8216;&gt;&#8217; characters get special treatment in XSL. So if you want them to appear in your output, you have to deal with the fact that XSL wants to convert the to their escape codes of   &amp;lt;   and   &amp;gt;   respectively. This is what the disable-output-escaping attribute does. XSL is already going to convert my &amp;lt;  and &amp;gt; codes to their respective characters on output &#8211; I don&#8217;t want them to be converted back to the escape codes.</p>
<p>So now you can see how the two &lt;xsl:text&gt; instructions create the beginning and end of the CDATA section.</p>
<p>Finally, the contents of the CDATA section is obtained using the &lt;xsl:value-of&gt; instruction, asking for the contents of the &lt;description&gt; node.</p>
<p>I want to point out one finally little trick here. In my case, the contents of the description node could contain other HTML, meaning &#8216;&lt;&#8217; and &#8216;&gt;&#8217; characters. I again used the disable-output-escaping attribute to prevent XSL from trying to be too smart.</p>
<p>Anyway, all that for a tiny bit of code. Maybe it will save you a little time since I found no full examples like this anywhere in my search.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rhbourdeau.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rhbourdeau.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rhbourdeau.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rhbourdeau.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rhbourdeau.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rhbourdeau.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rhbourdeau.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rhbourdeau.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rhbourdeau.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rhbourdeau.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rhbourdeau.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rhbourdeau.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rhbourdeau.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rhbourdeau.wordpress.com/32/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rhbourdeau.wordpress.com&amp;blog=14747606&amp;post=32&amp;subd=rhbourdeau&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rhbourdeau.wordpress.com/2010/07/30/preserving-cdata-sections-with-xsl-transformations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/feac57209c1dd61ab74f0a5c9c9aff9d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rhbourdeau</media:title>
		</media:content>
	</item>
		<item>
		<title>A simple way to see a RAW RSS file using Safari on MacOSX</title>
		<link>http://rhbourdeau.wordpress.com/2010/07/25/a-simple-way-to-see-a-raw-rss-file-using-safari-on-macosx/</link>
		<comments>http://rhbourdeau.wordpress.com/2010/07/25/a-simple-way-to-see-a-raw-rss-file-using-safari-on-macosx/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 16:58:26 +0000</pubDate>
		<dc:creator>rhbourdeau</dc:creator>
				<category><![CDATA[Helpful Technical Tips]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://rhbourdeau.wordpress.com/?p=26</guid>
		<description><![CDATA[I am building an RSS/ATOM aggregator and need to see the raw XML files corresponding to some RSS and ATOM feeds. The newer browsers are so incredibly helpful that they recognize these feeds and perform XSLT transforms on them to create a nice UI for viewing them.  That is extremely annoying if you are really [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rhbourdeau.wordpress.com&amp;blog=14747606&amp;post=26&amp;subd=rhbourdeau&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am building an RSS/ATOM aggregator and need to see the raw XML files corresponding to some RSS and ATOM feeds. The newer browsers are so incredibly helpful that they recognize these feeds and perform XSLT transforms on them to create a nice UI for viewing them.  That is extremely annoying if you are really after the actual raw XML file.</p>
<p>Wonderfully I finally found a way to subvert the XSLT processing:</p>
<ol>
<li>Go to the Safari menu</li>
<li>Choose Preferences</li>
<li>Click the RSS tab</li>
<li>Change &#8220;Default RSS Reader&#8221; to TextEdit.app</li>
</ol>
<p>Now load/reload your RSS file via Safari. TextEdit pops up with the raw feed displayed.  On to mapping these into my aggregated feed!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rhbourdeau.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rhbourdeau.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rhbourdeau.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rhbourdeau.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rhbourdeau.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rhbourdeau.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rhbourdeau.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rhbourdeau.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rhbourdeau.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rhbourdeau.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rhbourdeau.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rhbourdeau.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rhbourdeau.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rhbourdeau.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rhbourdeau.wordpress.com&amp;blog=14747606&amp;post=26&amp;subd=rhbourdeau&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rhbourdeau.wordpress.com/2010/07/25/a-simple-way-to-see-a-raw-rss-file-using-safari-on-macosx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/feac57209c1dd61ab74f0a5c9c9aff9d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rhbourdeau</media:title>
		</media:content>
	</item>
		<item>
		<title>How to view the XCode instructions to the compiler</title>
		<link>http://rhbourdeau.wordpress.com/2010/07/18/how-to-view-the-xcode-instructions-to-the-compiler/</link>
		<comments>http://rhbourdeau.wordpress.com/2010/07/18/how-to-view-the-xcode-instructions-to-the-compiler/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 17:00:14 +0000</pubDate>
		<dc:creator>rhbourdeau</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://rhbourdeau.wordpress.com/?p=9</guid>
		<description><![CDATA[I&#8217;m building an iPhone application and before I started I knew nothing at all about ObjectiveC, the Mac development environment, or much of anything else about the Mac world.  Both the syntax of ObjectiveC and the programming model for the iPhone have been challenges to absorb.  As such, some of the challenges I have faced [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rhbourdeau.wordpress.com&amp;blog=14747606&amp;post=9&amp;subd=rhbourdeau&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m building an iPhone application and before I started I knew nothing at all about ObjectiveC, the Mac development environment, or much of anything else about the Mac world.  Both the syntax of ObjectiveC and the programming model for the iPhone have been challenges to absorb.  As such, some of the challenges I have faced may be nothing new for the veteran Mac or iPhone developer.</p>
<p>My most recent problem is this. I want to incorporate XSLT into my iPhone app. I have already succeeded building in XML processing using libxml2. That took a little effort to be able to successfully configure XCode to compile and link against the libxml2 library. I figured that XSLT would be a done deal.</p>
<p>Most simply put, I have a reference to the XSLT libraries in my code as follows:</p>
<p style="padding-left:30px;"><code>#import &lt;libxslt/xslt.h&gt;</code></p>
<p>This and other XSLT files are located in <code>/usr/include</code> which one would expect is already part of the system search path. So my first question is &#8211; how do I know what the default system search paths are? I don&#8217;t know the answer to this question yet. The problem is that the compiler is spewing out the following error:</p>
<p style="padding-left:30px;"><code>error: libxslt/xslt.h: No such file or directory</code></p>
<p>I have tried adding <code>/usr/include</code> to the Project Setting &#8211; Header Search Path. The referenced files <strong>are</strong> here. It makes no difference. Interestingly, if I add <code>/usr/include/libxslt</code> as a search path, and change my code to reference the file as:</p>
<p style="padding-left:30px;"><code>#import &lt;xslt.h&gt;</code></p>
<p>I don&#8217;t get the error in my code, but the error is propagated to one of the system xslt files themselves.</p>
<p>However, this is a seemingly simple problem, and since I think I am properly configuring XCode to find these files, I have to wonder what the intructions are that XCode is passing to the compiler. Where is the compiler command line?</p>
<p>I FINALLY found this. If you <strong>right-click on the error message produced by XCode</strong>, you will see an option:</p>
<p style="padding-left:30px;"><em>Open the latest results as a transcript text file</em></p>
<p>Behold, a complete dump of the complete session of XCode interacting with the compiler.</p>
<p>I found the section of code pertaining to the specific source file that was troubling me. I looked for the compiler options <code>-I</code>, and did not find the path I had configured in Xcode. I did find one other interesting option being generated in the command line:</p>
<p><code>-I/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/usr/include/libxml2</code></p>
<p>I find this very interesting because I configured <code>libxml2</code> explicitly to be located in <code>/usr/include/libxml2</code>, not that deep path above. As an experiment, I added <code>-&nbsp;I/usr/include</code> to the compiler command line and the error disappeared. No doubt I won&#8217;t be able to build this for the iPhone device using this method.</p>
<p><strong>I have learned this</strong>,</p>
<ol>
<li>Path names in the project settings are not treated literally. They are treated as if they are relative to a specific platform/sdk subdirectory. This makes perfect sense and is an excellent idea since my settings are easily translated to different SDKs and devices without change. That is, assuming that the path exists in each of these subdirectories. And you won&#8217;t be told this during compilation. You just have to know this.</li>
<li>There is a context-sensitive menu attached to the compiler error messages presented by XCode that can produce the actually compiler session. In this case, it was invaluable to diagnosing the problem.</li>
</ol>
<p>In conclusion, what you put into the Project Settings in XCode is not treated literally. XCode tries to be very smart, and it is. But when it fails, figuring out what happened can be <em>mind boggling</em>. If I can get everything working, including building for the device, I&#8217;ll post a configuration solution.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rhbourdeau.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rhbourdeau.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/rhbourdeau.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/rhbourdeau.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/rhbourdeau.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/rhbourdeau.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/rhbourdeau.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/rhbourdeau.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/rhbourdeau.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/rhbourdeau.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/rhbourdeau.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/rhbourdeau.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/rhbourdeau.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/rhbourdeau.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rhbourdeau.wordpress.com&amp;blog=14747606&amp;post=9&amp;subd=rhbourdeau&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://rhbourdeau.wordpress.com/2010/07/18/how-to-view-the-xcode-instructions-to-the-compiler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/feac57209c1dd61ab74f0a5c9c9aff9d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rhbourdeau</media:title>
		</media:content>
	</item>
	</channel>
</rss>
