<?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>Webmaster-Source &#187; development</title>
	<atom:link href="https://www.webmaster-source.com/tag/development/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.webmaster-source.com</link>
	<description>Useful Resources For Webmasters</description>
	<lastBuildDate>Thu, 24 Aug 2017 02:01:18 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.42</generator>
	<item>
		<title>Fixing Slow Hosts File Lookups in OS X Mountain Lion</title>
		<link>https://www.webmaster-source.com/2012/11/14/fixing-slow-hosts-file-lookups-in-os-x-mountain-lion/</link>
		<comments>https://www.webmaster-source.com/2012/11/14/fixing-slow-hosts-file-lookups-in-os-x-mountain-lion/#comments</comments>
		<pubDate>Wed, 14 Nov 2012 11:58:47 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[servers]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=4869</guid>
		<description><![CDATA[Mac users with custom entries in their /etc/hosts files may have noticed that, under Mountain Lion at least, lookup times for local resources are incredibly slow. I routinely set up names that point to virtual hosts on my laptop so I can give projects their own local domain instead of having http://localhost/projects/something/index.php or somesuch. Typing [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Mac users with custom entries in their <code>/etc/hosts</code> files may have noticed that, under Mountain Lion at least, lookup times for local resources are incredibly slow. I routinely set up names that point to virtual hosts on my laptop so I can give projects their own local domain instead of having <code>http://localhost/projects/something/index.php</code> or somesuch. Typing <code>something.dev</code> is much easier. I noticed that, since upgrading from Snow Leopard to Mountain Lion, Firefox would spend several seconds trying to look up those names before consulting the hosts file and loading the page.</p>
<p>While I don&#8217;t know why it&#8217;s happening, exactly, I do have a fix. The wait goes away if you put the local entries on one line.</p>
<p>Instead of having something like this:</p>
<pre class="brush: plain; title: ; notranslate">
#virtual hosts
127.0.0.1 myproject.dev
127.0.0.1 wordpress.dev
127.0.0.1 somesuch.dev
</pre>
<p>You need to have this:</p>
<pre class="brush: plain; title: ; notranslate">
#virtual hosts
127.0.0.1 myproject.dev wordpress.dev somesuch.dev
</pre>
<p>Leave the lines that say &#8220;localhost&#8221; alone, of course. Messing with those could cause all manner of Bad Things.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2012/11/14/fixing-slow-hosts-file-lookups-in-os-x-mountain-lion/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Domain Hijackers Hit Design and Development Blogs</title>
		<link>https://www.webmaster-source.com/2011/12/05/domain-hijackers-hit-design-and-development-blogs/</link>
		<comments>https://www.webmaster-source.com/2011/12/05/domain-hijackers-hit-design-and-development-blogs/#comments</comments>
		<pubDate>Mon, 05 Dec 2011 12:17:22 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Domains]]></category>
		<category><![CDATA[Blogs]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[GoDaddy]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=4426</guid>
		<description><![CDATA[There has been a sudden outbreak of design and development blogs having their domain names hijacked and held for ransom. It seems to have started with David Walsh&#8217;s site, when his domain name was mysteriously transferred from GoDaddy to Name.com and from there to 1and1. The DNS records have been pointed back to Walsh&#8217;s host [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>There has been a sudden outbreak of design and development blogs having their domain names hijacked and held for ransom. It seems to have <a href="http://davidwalsh.name/domain-stolen">started with David Walsh&#8217;s site</a>, when his domain name was mysteriously transferred from GoDaddy to Name.com and from there to 1and1. The DNS records have been pointed back to Walsh&#8217;s host by 1and1 while things are sorted out, but for now the domain is still not under his control.</p>
<p>About one day later, <a href="http://css-tricks.com/15377-this-sites-domain-is-stolen/">the same thing happened</a> to Chris Coyier&#8217;s CSS-Tricks.com. Someone gained access to his GMail and GoDaddy accounts and moved the domain to PlanetDomain. From his detailed chronicle of the events, it&#8217;s a possibility that he may have a keylogger on his computer, as the miscreant has been able to get around password resets of the GMail account, and may have even accessed the Media Temple server CSS-Tricks is hosted on. Coyier also received the impeccably-penned threat &#8220;pay 2k to get ur domain back.&#8221;</p>
<p>This has recently happened to a few other big-name sites in the same field, including Abduzeedo, Kirupa, Design Shack and InstantShift. Abduzeedo was able to catch the transfer and stop it, though. (Interestingly, it has been almost exactly four years since the same thing happened to <a href="http://www.davidairey.com/david-airey-hacked/">logo designer David Airey</a>.)</p>
<p>Just to be on the safe side, you might want to do a quick <a href="http://www.whois.net/">WHOIS</a> search on your own domain and make sure it&#8217;s still on your registrar.</p>
<p><em>Update, Dec 5:</em> Planetdomain <a href="https://twitter.com/#!/chriscoyier/status/143856882073878529">is reversing the transfer</a>, and moving the CSS-Tricks.com domain back to Chris Coyier&#8217;s GoDaddy account.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2011/12/05/domain-hijackers-hit-design-and-development-blogs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Building an iPhone App to Parse the Twitter API with NSXMLParser</title>
		<link>https://www.webmaster-source.com/2011/10/24/building-an-iphone-app-to-parse-the-twitter-api-with-nsxmlparser/</link>
		<comments>https://www.webmaster-source.com/2011/10/24/building-an-iphone-app-to-parse-the-twitter-api-with-nsxmlparser/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 11:20:58 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=4362</guid>
		<description><![CDATA[iOS has a simple event-based XML parser built in, which makes it fairly easy to do less involved parsing operations without having to load up a third-party framework. This tutorial will show you how to build a simple iPhone application that will download an XML feed from Twitter containing a user&#8217;s tweets, and then display [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>iOS has a simple event-based XML parser built in, which makes it fairly easy to do less involved parsing operations without having to load up a third-party framework. This tutorial will show you how to build a simple iPhone application that will download an XML feed from Twitter containing a user&#8217;s tweets, and then display them with a pretty UI. (You could easily adapt this to parse other XML documents, such as RSS feeds.)</p>
<p style="text-align: center;"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-4364 imgborder" title="Displaying data from a Twitter XML feed in iOS" src="//www.webmaster-source.com/wp-content/uploads/nsxmlparser-example-fantasyfolder.jpg" alt="" width="600" height="306" /></p>
<h3><span id="more-4362"></span>Getting Started</h3>
<p>First, create a new View-based application. Give it a memorable name like &#8220;TwitterXML.&#8221;</p>
<p style="text-align: center;"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-4365 imgborder" title="Creating a view-based application in Xcode" src="//www.webmaster-source.com/wp-content/uploads/nsxmlparser-view-based-application.png" alt="" width="600" height="471" /></p>
<p>Now that you have a clean slate to work off, let&#8217;s rename some classes. I find Xcode&#8217;s default naming scheme a bit silly, with the way it prepends the project name to each file. I think the Application Delegate should be called, simply, <em>AppDelegate.m</em> instead of the needlessly long <em>TwitterXMLAppDelegate.m.</em> However, you can&#8217;t just rename the file to whatever your preference is, as that would break things.</p>
<p>You can rename a class project-wide, file and all, by using the Refactoring tool. You can call it up by right-clicking on the class name in the implementation file and choosing &#8220;Refactoring&#8221; from the resulting menu.</p>
<p><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-4366" title="Renaming classes with the Refactor tool" src="//www.webmaster-source.com/wp-content/uploads/nsxmlparser-renaming-classes-with-refactor-tool.png" alt="" width="600" height="352" /></p>
<p>This renaming business is entirely optional as far as this tutorial goes, but it&#8217;s worth know how to do. Imagine if you made a typo in a class name and didn&#8217;t realize it until after you had already referenced it in a few places. It&#8217;s nice to have an automated fix.</p>
<h3>Setting Up the Header File</h3>
<p>Most of our code is going to go in the View controller, named <em>TweetViewController</em> in my case. Switch to the corresponding .h file and we can start setting up properties and whatnot.</p>
<p>First, we need to implement the NSXMLParserDelegate protocol so our class can respond to NSXMLParser delegate methods. This is easily done by adding <em>NSXMLParserDelegate</em> to the <em>@interface</em> line, like so:</p>
<pre class="brush: cpp; title: ; notranslate">
@interface TweetViewController : UIViewController &lt;NSXMLParserDelegate&gt; {
</pre>
<p>Now we need to declare some variables and other objects in the interface block. We need a string to hold the name of the Twitter user whose profile we will be accessing, a mutable array to hold the statuses we&#8217;ve pulled from the parser and a few that are used to hold data temporarily during the parsing process. Also, we need a few IBOutlets so we can update the View once we finish reading the XML data.</p>
<pre class="brush: cpp; title: ; notranslate">
@interface TweetViewController : UIViewController &lt;NSXMLParserDelegate&gt; {
NSString *twitterUser;
NSMutableArray *statuses;
NSString *currentElement;
NSMutableDictionary *currentElementData;
NSMutableString *currentElementString;
IBOutlet UIImageView *backgroundImage;
IBOutlet UILabel *tweetLabel;
IBOutlet UIImageView *avatar;
}
</pre>
<p>Of course, we need to make these objects into properties. This means adding a few property declarations after the interface block ends.</p>
<pre class="brush: cpp; title: ; notranslate">
@property (nonatomic, retain) NSString *twitterUser;
@property (nonatomic, retain) NSMutableArray *statuses;
@property (nonatomic, retain) NSString *currentElement;
@property (nonatomic, retain) NSMutableDictionary *currentElementData;
@property (nonatomic, retain) NSMutableString *currentElementString;
@property (nonatomic, retain) UIImageView *backgroundImage;
@property (nonatomic, retain) UILabel *tweetLabel;
@property (nonatomic, retain) UIImageView *avatar;
</pre>
<p>And then you need to synthesize them in the .m file by adding the following line right after the @implementation line:</p>
<pre class="brush: cpp; title: ; notranslate">
@synthesize twitterUser, statuses, currentElement, currentElementData, currentElementString, backgroundImage, tweetLabel, avatar;
</pre>
<p>Now that that&#8217;s out of the way, we can get to the interesting part.</p>
<h3>Setting Up the Parser</h3>
<p>The first method in the View controller is &lt;em&gt;viewDidLoad&lt;/em&gt;, which fires as soon as the View as loaded. (Subtle, isn&#8217;t it?) We will be putting our initialization stuff in there. Basically, we just need to ready our properties, set the Twitter username and start the parser.</p>
<pre class="brush: cpp; title: ; notranslate">
- (void)viewDidLoad {
[super viewDidLoad];
statuses = [[NSMutableArray alloc] init];
currentElement = [[NSString alloc] init];
currentElementData = [[NSMutableDictionary alloc] init];
currentElementString = [[NSMutableString alloc] init];
twitterUser = [NSString stringWithString:@&quot;collis&quot;];
[self parseXMLForUser:twitterUser];
}
</pre>
<p>After the first arrays and dictionaries are initialized, the <em>twitterUser</em> string is set to the username of the Twitter account we want the app to pull the latest statuses from. I&#8217;m using <a href="http://twitter.com/#!/collis">Collis</a>, one of the co-founders of <a href="http://envato.com/">Envato</a>, as an example. You could put any user you want there, so long as they have a cool-looking background on their profile!</p>
<p>The last line calls the <em>parseXMLForUser:</em> method and passes the <em>twitterUser</em> string along with it. We will work on that part next.</p>
<p>The <em>parseXMLForUser:</em> method is responsible for setting up the parser, as well as building the Twitter API URL.</p>
<pre class="brush: cpp; title: ; notranslate">
- (void)parseXMLForUser:(NSString *)user {

//Build the Twitter API URL by combining the user with the rest of the URL
NSString *urlString = [NSString stringWithFormat:@&quot;http://twitter.com/statuses/user_timeline/%@.xml?count=3&quot;, user];
NSURL *url = [NSURL URLWithString:urlString];

//Create an instance of NSXMLParser and download the XML data from the URL
NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:url];

//Set this class as its own delegate so we can process NSXMLParser callbacks
[parser setDelegate:self];

//Disable namespace support and other things we don't really need
[parser setShouldProcessNamespaces:NO];
[parser setShouldReportNamespacePrefixes:NO];
[parser setShouldResolveExternalEntities:NO];

[parser parse]; //Go go gadget XML parser...

[parser release];

}
</pre>
<p>The first part of the method should look familiar to anyone who has worked with C or Java before. It takes our <em>user</em> argument (which contains the text of <em>twitterUser</em>) and splices it into the URL string, just before the <em>.xml</em> part. Cocoa expects URLs to be of the NSURL object type, we create a new one of those and pass it <em>urlString</em>.</p>
<p>After that is done, we create a new instance of the NSXMLParser class and nickname it &#8220;parser.&#8221; We also pass it the new URL object, which it will use to download the contents it finds there at runtime. Next we set the parser&#8217;s delegate to <em>self</em>, or the current class. The next three lines turn off some features we don&#8217;t really need. Finally, we kick the parser into action and leave a <em>[parser release]</em> command to clean up after it&#8217;s done.</p>
<p>That was simple, wasn&#8217;t it? Sadly, that was only the beginning. In order for the parser to, well, <em>parse</em> we still need to implement the delegate methods for NSXMLParser. And we need to make a spiffy UI.</p>
<h3>Building the Parser</h3>
<p>NSXMLParser is what is called an event-based parser. This means it loops around, searching a document for anything that looks like an XML tag. When it finds one, it raises an event. Basically it says &#8220;I found an opening tag named &#8216;something'&#8221; and leaves you to deal with it. The parser does the same thing with ending tags and the text between them. We have to implement delegate methods to handle these events and save the data they find.</p>
<p>Let&#8217;s start with a couple of simple ones.</p>
<pre class="brush: cpp; title: ; notranslate">
- (void)parserDidStartDocument:(NSXMLParser *)parser {
NSLog(@&quot;The XML document is now being parsed.&quot;);
}

- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError {
NSLog(@&quot;Parse error: %d&quot;, [parseError code]);
}
</pre>
<p>The first method fires when NSXMLParser starts to parse the document. For this application, there isn&#8217;t really anything that we need to do at that point. Putting an NSLog there is great for debugging, though. (If your app is crashing, it&#8217;s helpful to know whether it&#8217;s getting to that step or not.) I&#8217;m sure you can guess what the <em>parseErrorOccurred</em> method does. (It logs an error code if the XML document is malformed or if, for some other reason, the parser could not process it.)</p>
<p>Moving on, we have a method that is called when the parser finds an opening XML tag.</p>
<pre class="brush: cpp; title: ; notranslate">
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {

//Store the name of the element currently being parsed.
currentElement = [elementName copy];

//Create an empty mutable string to hold the contents of elements
currentElementString = [NSMutableString stringWithString:@&quot;&quot;];

//Empty the dictionary if we're parsing a new status element
if ([elementName isEqualToString:@&quot;status&quot;]) {
[currentElementData removeAllObjects];
}

}
</pre>
<p>This one is a bit more complicated. When it&#8217;s called, its arguments are populated with information that the parser found out about the element currently being parsed. It&#8217;s name is what we care about, primarily. Using the properties we created earlier, the method keeps track of the element currently being parsed (we need to know its name in other methods) and whatever is <em>inside</em> the element (between the opening and closing tag). The conditional statement at the end empties our dictionary every time the parser moves on to a new &lt;status&gt; element, as we will have already copied its contents to the statuses array.</p>
<p>The next delegate method takes any characters found inside an XML element and stores it in the <em>currentElementString</em> property for later.</p>
<pre class="brush: cpp; title: ; notranslate">
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
//Take the string inside an element (e.g. &lt;tag&gt;string&lt;/tag&gt;) and save it in a property
[currentElementString appendString:string];
}
</pre>
<p>And finally, the penultimate method. This one contains the real meat of the parser. It is called whenever NSXMLParser comes across a closing XML tag. And so, it serves as a good place to put most of the data-saving logic.</p>
<pre class="brush: cpp; title: ; notranslate">
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {

//If we've hit the &lt;/status&gt; tag, store the data in the statuses array
if ([elementName isEqualToString:@&quot;status&quot;]) {
[statuses addObject:[currentElementData copy]];
}

//Trim any extra spaces and newline characters from around currentElementString
NSString *string = [currentElementString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

//Store the status data in the currentElementData dictionary
if ([currentElement isEqualToString:@&quot;created_at&quot;]) {
[currentElementData setObject:string forKey:@&quot;created_at&quot;];
} else if ([currentElement isEqualToString:@&quot;text&quot;]) {
[currentElementData setObject:string forKey:@&quot;text&quot;];
} else if ([currentElement isEqualToString:@&quot;retweeted&quot;]) {
[currentElementData setObject:string forKey:@&quot;retweeted&quot;];
} else if ([currentElement isEqualToString:@&quot;id&quot;]) {
[currentElementData setObject:string forKey:@&quot;id&quot;];
} else if ([currentElement isEqualToString:@&quot;profile_image_url&quot;]) {
[currentElementData setObject:string forKey:@&quot;profile_image_url&quot;];
} else if ([currentElement isEqualToString:@&quot;profile_background_image_url&quot;]) {
[currentElementData setObject:string forKey:@&quot;profile_background_image_url&quot;];
} else if ([currentElement isEqualToString:@&quot;profile_link_color&quot;]) {
[currentElementData setObject:string forKey:@&quot;profile_link_color&quot;];
}

}
</pre>
<p>The first code chunk saves the contents of the <em>currentElementData</em> dictionary to the <em>statuses</em> array if, and only if, the ending tag being processed currently is &lt;/status&gt;. If you remember from before, <em>currentElementData</em> will be emptied the next time the <em>didStartElement</em> method is called. Otherwise, the block will be skipped and the application will handle the tasks it needs to run for child elements of &lt;status&gt;.</p>
<p>After stripping out extraneous spaces and newline characters from either side of <em>currentElementString</em>, so we don&#8217;t end up with weird output, we have a rather long if/else if block. This checks whether the element being parsed is one we want to save (e.g. &#8220;text&#8221; or &#8220;profile_image_url&#8221;) and if it is, it adds it to the element data dictionary.</p>
<p>The code may seem a bit strange at first, but it should make more sense after you become more familiar with it.</p>
<p>And now, for the last delegate method. This one fires when the document has finished parsing. This is the place to launch any operations we want to be started after we have our data. As you can see below, logging the <em>statuses</em> array to the console and then calling a method to display that data is what we will be doing here.</p>
<pre class="brush: cpp; title: ; notranslate">
- (void)parserDidEndDocument:(NSXMLParser *)parser {
//Document has been parsed. It's time to fire some new methods off!
NSLog(@&quot;%@&quot;, statuses);
[self updateView];
}
</pre>
<h3>The View</h3>
<p>After all that code, let&#8217;s work on the interface. Double-click the <em>TweetViewController.xib</em> file (or whatever your View XIB is called) in the Xcode sidebar to open it in Interface Builder. Now that your screen is sufficiently cluttered with windows, you want to drag a UIImageView from the Library window into your View canvas. Make sure that it is sized to fit the whole available area.</p>
<p>Of course, the Image View won&#8217;t be much use to us unless we link it with the controller. Right-click on the File&#8217;s Owner icon and drag the little rubberband/wire thing from the <em>backgroundImage</em> Outlet over to the UIImageView and drop it. The File&#8217;s Owner overlay window should update to show the Image View as being connected to <em>backgroundImage</em>.</p>
<p style="text-align: center;"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-4367 imgborder" title="Adding a UIImageView in Interface Builder" src="//www.webmaster-source.com/wp-content/uploads/nsxmlparser-ib-adding-uiimageview.png" alt="" width="600" height="440" /></p>
<p>I think this app would be better if it used a horizontal orientation, don&#8217;t you? Click the little arrow icon in the upper right corner of the View canvas. Interface Builder should automagically resize the Image View inside it to still fill the View. Save the XIB file out and switch back to Xcode. Now we have to configure the application to use a landscape orientation instead of the default portrait one.</p>
<p>Inside your controller class there should be a method called <em>shouldAutorotateToInterfaceOrientation</em>. It&#8217;s commented out by default. Uncomment it and change the interfaceOrientation to <em>UIInterfaceOrientationLandscapeLeft</em>. It should look like this:</p>
<pre class="brush: cpp; title: ; notranslate">
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
</pre>
<p>Back in Interface Builder, drop in a new UIImageView. We won&#8217;t be hooking this one up to an IBOutlet. Instead, we will set the image to the word bubble image I made (it&#8217;s in the project file), resize the view to be the same point-width as the image (375&#215;208) and position it neatly over the background image view. I also lowered the opacity a bit, just because I liked the effect.</p>
<p>Now we need a way to display the contents of the latest tweet. So drag a UILabel onto the View canvas and resize it to fit nicely over the word bubble graphic. Turn the &#8220;# Lines&#8221; setting up to five or so, set the font size to something that looks legible and change the &#8220;Line Breaks&#8221; option to &#8220;Word Wrap. Then wire it up to the <em>tweetLabel</em> IBOutlet, like you did with the UIImageView.</p>
<p><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-4368" title="Adding the Label" src="//www.webmaster-source.com/wp-content/uploads/nsxmlparser-adding-the-label.png" alt="" width="600" height="421" /></p>
<p>Ready to tie everything together? Switch back to Xcode and add one last method to the controller class.</p>
<pre class="brush: cpp; title: ; notranslate">
- (void)updateView {

//Select the latest tweet
NSDictionary *latestTweet = [statuses objectAtIndex:0];

//Set the tweet label
[tweetLabel setText:[latestTweet objectForKey:@&quot;text&quot;]];

//Set the background image after downloading it.
NSString *urlString = [latestTweet objectForKey:@&quot;profile_background_image_url&quot;];
NSURL *url = [NSURL URLWithString:urlString];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *background = [[UIImage alloc] initWithData:data];
[backgroundImage setImage:background];
backgroundImage.contentMode = UIViewContentModeScaleAspectFill;

}
</pre>
<p>While it looks nearly as intimidating as the NSXMLParser <em>didEndElement</em> delegate method, it&#8217;s actually quite a bit simpler. The first line gets the newest tweet from the <em>statuses</em> array, the =<em>[tweetLabel setText:&#8230;]</em>= line updates the UILabel with the text of the message, and the last part changes the background image behind the word bubble to be the same as the Twitter user&#8217;s profile background.</p>
<p>That last part needs the most explanation. Before we can display the image (which is what the <em>setImage</em> line does) we have to download it first. Taking the <em>urlString</em>, which of course is a string containing the web address where the image can be found, we convert it to a NSURL object, which is named <em>url</em>. We create a new NSData object and use it&#8217;s <em>dataWithContentsOfURL</em> method to download the image. (Cocoa requires that URLs used with it&#8217;s objects be of the NSURL class.) Next we initialize a UIImage object with the NSData object and set it as the image in the UIImageView named backgroundImage. Oh, and we set the content mode to <em>UIViewContentModeScaleAspectFill</em> so it&#8217;s not squished funny.</p>
<p>Now if you build and run the app, you should get something like this:</p>
<p style="text-align: center;"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-4369 imgborder" title="A styled tweet in the iOS app" src="//www.webmaster-source.com/wp-content/uploads/nsxmlparser-first-demo-tweet-on-bg.png" alt="" width="600" height="394" /></p>
<p>Before we free up our allocated memory and finish the app up, let&#8217;s add one more thing: an avatar field! Switch back to Interface Builder and add a new UIImageView. Resize it to 52&#215;52 or so and wire it up to the &#8220;avatar&#8221; IBOutlet. Re-using the code from the background image bit, we can quickly modify it for the avatar.</p>
<pre class="brush: cpp; title: ; notranslate">
//Set the avatar image after downloading it.
NSString *avatarUrlString = [latestTweet objectForKey:@&quot;profile_image_url&quot;];
NSURL *avatarUrl = [NSURL URLWithString:avatarUrlString];
NSData *avatarData = [NSData dataWithContentsOfURL:avatarUrl];
UIImage *avatarImage = [[UIImage alloc] initWithData:avatarData];
[avatar setImage:avatarImage];
avatar.contentMode = UIViewContentModeScaleAspectFill;
</pre>
<p>That goes in the <em>updateView</em> method, after everything else.</p>
<p>Now, before we can say the application is finished, there is one thing that needs to be done. Any memory we specifically allocated should be released. It&#8217;s not a huge deal in a single-view app, as it will be forcefully freed up on exit, but it&#8217;s a good habit to get into. (In more complicated applications, you can expect to see frequent crashes if you don&#8217;t release objects when you&#8217;re done with them.) It&#8217;s easy to do. For every object we explicitely <em>alloc</em> or <em>retain</em>, we have to <em>release</em> somewhere. The <em>dealloc</em> method is called when the application quits in this case, so we put most of our <em>release</em> statements there.</p>
<p>You can learn more about iOS memory management in <a href="http://mobile.tutsplus.com/freebies/qa-sessions/qa-session-3-ios-memory-management-and-best-practices/">this screencast</a>.</p>
<pre class="brush: cpp; title: ; notranslate">
- (void)dealloc {
[twitterUser release];
[statuses release];
[currentElement release];
[currentElementData release];
[currentElementString release];
[backgroundImage release];
[tweetLabel release];
[avatar release];
[super dealloc];
}
</pre>
<p>And we&#8217;re done!</p>
<p style="text-align: center;"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-4370 imgborder" title="And we're done!" src="//www.webmaster-source.com/wp-content/uploads/nsxmlparser-final.png" alt="" width="505" height="342" /></p>
<h3>Additional Challenge</h3>
<p>Want to add to this sample application? Try making the following change: Use an <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSTimer_Class/Reference/NSTimer.html">NSTimer</a> to cycle through the items in the <em>statuses</em> array and update the View accordingly. Most of the groundwork has been laid for you already.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2011/10/24/building-an-iphone-app-to-parse-the-twitter-api-with-nsxmlparser/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>WordPress BlackBox Debug Bar Plugin</title>
		<link>https://www.webmaster-source.com/2011/04/20/wordpress-blackbox-debug-bar-plugin/</link>
		<comments>https://www.webmaster-source.com/2011/04/20/wordpress-blackbox-debug-bar-plugin/#comments</comments>
		<pubDate>Wed, 20 Apr 2011 11:37:21 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Plugins]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=3959</guid>
		<description><![CDATA[BlackBox is a handy WordPress plugin that I&#8217;m going to have to try out for development. It adds a debug bar along the top of each page, with items that would be invaluable for plugin and theme developers but probably of little interest to bloggers who don&#8217;t like getting under the hood. With the theme [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><a href="http://ditio.net/2011/01/29/wordpress-debug-bar-plugin-blackbox/">BlackBox</a> is a handy WordPress plugin that I&#8217;m going to have to try out for development. It adds a debug bar along the top of each page, with items that would be invaluable for plugin and theme developers but probably of little interest to bloggers who don&#8217;t like getting under the hood.</p>
<p>With the theme you can have a look at all of the globals, see any errors generated, and keep tabs on the MySQL queries (including their execution times) behind the page generation. It even includes a profiler.</p>
<p style="text-align: center;"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-3960 imgborder" title="BlackBox WordPress Debug Bar" src="//www.webmaster-source.com/wp-content/uploads/blackbox-wordpress-debug-bar.png" alt="" width="540" height="83" /></p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2011/04/20/wordpress-blackbox-debug-bar-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TestFlight: iOS Beta Testing on the Fly</title>
		<link>https://www.webmaster-source.com/2011/02/23/testflight-ios-beta-testing-on-the-fly/</link>
		<comments>https://www.webmaster-source.com/2011/02/23/testflight-ios-beta-testing-on-the-fly/#comments</comments>
		<pubDate>Wed, 23 Feb 2011 11:43:36 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Services and Tools]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[developers]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=3917</guid>
		<description><![CDATA[If you&#8217;ve ever tried a little iPhone development out, you might have run into an inconvenient problem. Apple uses a code signing system on iOS devices to ensure that software that ends up on them has either passed through the App Store (and has thus been checked for malware-like behavior) or has been assigned to [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;ve ever tried a little iPhone development out, you might have run into an inconvenient problem. Apple uses a code signing system on iOS devices to ensure that software that ends up on them has either passed through the App Store (and has thus been checked for malware-like behavior) or has been assigned to the unique device ID using an ad-hoc distribution. This is generally good for the end user, but it&#8217;s a real pain to distribute betas.</p>
<p>Enter <a href="http://testflightapp.com/">TestFlight</a>.</p>
<p style="text-align: center;"><a href="http://testflightapp.com/"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter size-full wp-image-3918 imgborder" title="TestFlight" src="//www.webmaster-source.com/wp-content/uploads/testflight-homepage.jpg" alt="" width="600" height="326" /></a></p>
<p>I&#8217;m not sure how it does it, but TestFlight takes the pain out of iOS beta distribution. You just build an app, upload it, enter some email addresses, and TestFlight magically takes care of the rest.</p>
<p>When a beta tester gets an email from TestFlight, they register their device by logging into the TestFlight website on their iOS device. It installs a provisioning profile over the air, and lets them access your uploaded application builds in the same way.</p>
<p>However it does its magic, TestFlight is an indispensable tool for developers.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2011/02/23/testflight-ios-beta-testing-on-the-fly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone Application Development For Dummies</title>
		<link>https://www.webmaster-source.com/2010/02/24/iphone-application-development-for-dummies/</link>
		<comments>https://www.webmaster-source.com/2010/02/24/iphone-application-development-for-dummies/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 11:12:03 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=3068</guid>
		<description><![CDATA[Have you ever wanted to learn how to write your own iPhone applications? It&#8217;s certainly more difficult than web development, but the device is a good platform to learn client-side programming with. Mobile applications that tie into web services are becoming increasingly common, so now is a good time to give it a try. iPhone [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.amazon.com/iPhone-Application-Development-Dummies-Goldstein/dp/0470568437/webmasterso0d-20"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="alignright size-full wp-image-3069 imgborder" title="iPhone Application Development for Dummies" src="//www.webmaster-source.com/wp-content/uploads/iphone-application-development-dummies.jpg" alt="" width="130" height="162" /></a>Have you ever wanted to learn how to write your own iPhone applications? It&#8217;s certainly more difficult than web development, but the device is a good platform to learn client-side programming with. Mobile applications that tie into web services are becoming increasingly common, so now is a good time to give it a try.</p>
<p><em><a href="http://www.amazon.com/iPhone-Application-Development-Dummies-Goldstein/dp/0470568437/webmasterso0d-20">iPhone Application Development For Dummies</a></em> is a good primer on building applications for the iPhone or iPod Touch. It covers the basic theory over the first few chapters, and then moves on to building a simple View-based application. I haven&#8217;t finished the book quite yet, as I&#8217;m working my way through the tutorials as I read, but the book seems to cover all of the basics quite well. There are parts on data storage, input events, and many other things that are critical to iPhone development.</p>
<p>I&#8217;m finding the book to be a bit challenging, as I don&#8217;t have any real desktop programming experience, other than BASIC if that counts. I don&#8217;t think I&#8217;d recommend it to someone who doesn&#8217;t have a strong grasp of at least one programming language with a C-style syntax, such as PHP or Java. Knowledge of object-oriented programming is important, in addition to more basic skills such as dealing with variables and control structures. If you&#8217;re a total programming newbie, I would recommend reading a good introductory book first, and then moving on to <em>iPhone Application Development for Dummies.</em></p>
<p>I&#8217;ve enjoyed what I&#8217;ve read of the book so far, and I hope that, by the time I&#8217;m done, I&#8217;ll have a good enough grasp of things to develop an idea I&#8217;ve had for awhile into an app.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2010/02/24/iphone-application-development-for-dummies/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Twitter API is For Twitter</title>
		<link>https://www.webmaster-source.com/2009/12/30/the-twitter-api-is-for-twitter/</link>
		<comments>https://www.webmaster-source.com/2009/12/30/the-twitter-api-is-for-twitter/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 11:13:37 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Social Media]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=2877</guid>
		<description><![CDATA[Scott Gilbertson of Webmonkey&#8217;s MonkeyBites blog has an interesting post about the Twitter API, more specifically, on how some blog software providers are &#8220;borrowing&#8221; Twitter&#8217;s programmer interface to enable clients such as Tweetie to update your blog. Twitter’s API has spawned hundreds of mashups and third party software apps, but now it’s growing even further [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Scott Gilbertson of Webmonkey&#8217;s MonkeyBites blog has <a href="http://www.webmonkey.com/blog/Twitter_API_Is_Becoming_Far_More_than_Just_an_API_for_Twitter">an interesting post about the Twitter API</a>, more specifically, on how some blog software providers are &#8220;borrowing&#8221; Twitter&#8217;s programmer interface to enable clients such as Tweetie to update your blog.</p>
<blockquote><p>Twitter’s API has spawned hundreds of mashups and third party software apps, but now it’s growing even further — outside sites have begun mimicking an API to piggyback on Twitter clients.</p>
<p>It started last week with a clever hack by WordPress contributors which allows WordPress.com users to <a href="http://en.blog.wordpress.com/2009/12/12/twitter-api/">post and read their WordPress.com blogs through third-party Twitter apps</a> like Tweetie 2 for the iPhone.</p>
<p>Now Tumblr has joined in on the fun, allowing you to <a href="http://staff.tumblr.com/post/287703110/api">post and read Tumblr blogs</a> through any third-party Twitter app that allows you to change the API endpoint.</p></blockquote>
<p>While that&#8217;s interesting, I don&#8217;t really like it. Emulating another service&#8217;s API will only result in problems as Twitter updates their API methods. Developers of Twitter clients will update their software, and companies like WordPress.com will have to be quick to re-work their fake Twitter API, otherwise things could break. It just seems like a bad plan to base something like that off of a third party&#8217;s proprietary framework, rather than that of an open standard.<span id="more-2877"></span></p>
<p>Gilbertson continues to mention Dave Winer&#8217;s thoughts on how Twitter&#8217;s API is (without Twitter&#8217;s consent) becoming an &#8220;open standard,&#8221; and how that&#8217;s a <em>bad idea</em>.</p>
<blockquote><p>For one thing, Twitter is a private company with its own goals for its own API. In order to really become a standard, Twitter would need to freeze its API, ensuring that it doesn’t change. Since Twitter has been doing interesting (and sometimes backwards-incompatible) things with it, like adding geotagging support and changing how replies are handled, and we don’t want to see that stop.</p></blockquote>
<p>But honestly, is it <em>really</em> that hard to switch to a dedicated application to update your blog? WordPress provides an iPhone application for just that purpose, and it doesn&#8217;t have a 140 character limit.</p>
<p><a href="http://www.webmonkey.com/blog/Twitter_API_Is_Becoming_Far_More_than_Just_an_API_for_Twitter">Twitter API Is Becoming Far More than Just an API for Twitter</a> [MonkeyBites]</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2009/12/30/the-twitter-api-is-for-twitter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress&#8217;s WPDB Class</title>
		<link>https://www.webmaster-source.com/2009/10/19/wordpresss-wpdb-class/</link>
		<comments>https://www.webmaster-source.com/2009/10/19/wordpresss-wpdb-class/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 11:42:43 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=2647</guid>
		<description><![CDATA[WordPress has a class, $wpdb, that contains several useful functions for manipulating the database. (The $wpdb object is a global variable that WordPress automatically creates.) This is used throughout the core, and by plugin and theme developers to easily run custom MySQL operations. It even has functions for building and executing prepared statements. You can [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>WordPress has a class, $wpdb, that contains several useful functions for manipulating the database. (The $wpdb object is a global variable that WordPress automatically creates.) This is used throughout the core, and by plugin and theme developers to easily run custom MySQL operations. It even has functions for building and executing prepared statements.</p>
<p>You can find a nice introduction and examples <a href="http://wpengineer.com/wordpress-database-functions/">at WP Engineer</a>. Here&#8217;s a sample of how you would go about changing the title of a post with a certain ID:</p>
<pre class="brush: php; title: ; notranslate">
$wpdb-&gt;update( $wpdb-&gt;posts, array( 'post_title' =&gt; $new_post_title ),
 array( 'ID' =&gt; $the_post_id ) );
</pre>
<p>That&#8217;s just scratching the surface, but it gives a good idea of how the database functions work.</p>
<p>For even more in-depth reading, there&#8217;s a good <a href="http://codex.wordpress.org/Function_Reference/wpdb_Class">Codex page</a> on the subject as well.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2009/10/19/wordpresss-wpdb-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/


Served from: www.webmaster-source.com @ 2026-05-20 14:46:14 by W3 Total Cache
-->