<?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>James Border &#187; Objective&#045;C</title>
	<atom:link href="http://jamesborder.com/category/objectivec/feed/" rel="self" type="application/rss+xml" />
	<link>http://jamesborder.com</link>
	<description>Interactive/Mobile/iOS Developer</description>
	<lastBuildDate>Fri, 03 Feb 2012 03:17:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Objective-C PNG Sequence</title>
		<link>http://jamesborder.com/2012/02/objective-c-png-sequence/</link>
		<comments>http://jamesborder.com/2012/02/objective-c-png-sequence/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 03:17:49 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[Objective-C]]></category>

		<guid isPermaLink="false">http://jamesborder.com/?p=994</guid>
		<description><![CDATA[NSMutableArray *imageArray = [[NSMutableArray alloc]init]; for (int i = 1; iy]]></description>
			<content:encoded><![CDATA[<p>	NSMutableArray *imageArray = [[NSMutableArray alloc]init];</p>
<p>	for (int i = 1; iy <= 40; i++) {<br />
		[imageArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"s%02i.png", i]]];<br />
	}</p>
<p>	UIImageView * ryuJump = [[[UIImageView alloc] initWithFrame:<br />
							 CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)]autorelease];<br />
	ryuJump.animationImages = imageArray;<br />
	ryuJump.animationDuration = 2.1;<br />
	ryuJump.contentMode = UIViewContentModeCenter;</p>
<p>	[someview addSubview:ryuJump];</p>
<p>	[ryuJump startAnimating];<br />
	[imageArray release];</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesborder.com/2012/02/objective-c-png-sequence/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective-C urlencode/urldecode</title>
		<link>http://jamesborder.com/2012/02/objective-c-urlencodeurldecode/</link>
		<comments>http://jamesborder.com/2012/02/objective-c-urlencodeurldecode/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 19:03:47 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[Objective-C]]></category>

		<guid isPermaLink="false">http://jamesborder.com/?p=991</guid>
		<description><![CDATA[-(NSString*)urlEncoded:(NSString*)str { NSString *escapedUrlString = [str stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]; return escapedUrlString; } -(NSString*)urlDecoded:(NSString*)str { NSString *cleanUrlString = [str stringByReplacingPercentEscapesUsingEncoding:NSASCIIStringEncoding]; return cleanUrlString; } NSString *devStr = @&#8221;http://localhost/dri/json?foo=#bar&#038;something=true&#038;miscc=Foo bar!&#8221;; NSLog(@&#8221;devStr: %@&#8221;,devStr); NSString *encString = [self urlEncoded:devStr]; NSLog(@&#8221;encString: %@&#8221;,encString); NSString *decString = [self urlDecoded:encString]; NSLog(@&#8221;decString: %@&#8221;,decString);]]></description>
			<content:encoded><![CDATA[<p>-(NSString*)urlEncoded:(NSString*)str {</p>
<p>    NSString *escapedUrlString = [str stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];<br />
    return escapedUrlString;</p>
<p>}</p>
<p>-(NSString*)urlDecoded:(NSString*)str {</p>
<p>    NSString *cleanUrlString =  [str stringByReplacingPercentEscapesUsingEncoding:NSASCIIStringEncoding];<br />
    return cleanUrlString;</p>
<p>}</p>
<p>    NSString *devStr = @&#8221;http://localhost/dri/json?foo=#bar&#038;something=true&#038;miscc=Foo bar!&#8221;;</p>
<p>    NSLog(@&#8221;devStr: %@&#8221;,devStr);</p>
<p>    NSString *encString = [self urlEncoded:devStr];<br />
    NSLog(@&#8221;encString: %@&#8221;,encString);</p>
<p>    NSString *decString = [self urlDecoded:encString];<br />
    NSLog(@&#8221;decString: %@&#8221;,decString);</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesborder.com/2012/02/objective-c-urlencodeurldecode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective-C UIImage -&gt; UIImageView</title>
		<link>http://jamesborder.com/2012/02/objective-c-uiimage-uiimageview/</link>
		<comments>http://jamesborder.com/2012/02/objective-c-uiimage-uiimageview/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 05:27:07 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[Objective-C]]></category>

		<guid isPermaLink="false">http://jamesborder.com/?p=988</guid>
		<description><![CDATA[UIImage *image = [UIImage imageNamed:@"greatimage.png"]; UIImageView *imgView = [[UIImageView alloc] initWithImage:image]; imgView.frame = CGRectMake(0, 0, 320, 90); [self.view addSubview:imgView]; [imgView release];]]></description>
			<content:encoded><![CDATA[<p>	UIImage *image = [UIImage imageNamed:@"greatimage.png"];<br />
	UIImageView *imgView = [[UIImageView alloc] initWithImage:image];<br />
	imgView.frame = CGRectMake(0, 0, 320, 90);<br />
	[self.view addSubview:imgView];<br />
	[imgView release];</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesborder.com/2012/02/objective-c-uiimage-uiimageview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective-C UIButton</title>
		<link>http://jamesborder.com/2012/02/objective-c-uibutton/</link>
		<comments>http://jamesborder.com/2012/02/objective-c-uibutton/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 05:16:48 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[Objective-C]]></category>

		<guid isPermaLink="false">http://jamesborder.com/?p=984</guid>
		<description><![CDATA[// a button UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button addTarget:self action:@selector(targetMethod:) forControlEvents:UIControlEventTouchDown]; [button setTitle:@"Show View" forState:UIControlStateNormal]; button.frame = CGRectMake(0.0, 0.0, 160.0, 40.0); [self.view addSubview:button]; //////////////////////////////////////// // Button with background images //////////////////////////////////////// UIButton *bttn = [UIButton buttonWithType:UIButtonTypeCustom]; bttn.frame = CGRectMake(0, 200, 97, 38); [bttn setTitle:@"Dev One" forState:UIControlStateNormal]; [bttn addTarget:self action:@selector(targetMethod:) forControlEvents:UIControlEventTouchUpInside]; UIImage *bttnImageNormal = [UIImage imageNamed:@"button.png"]; <a href='http://jamesborder.com/2012/02/objective-c-uibutton/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>// a button<br />
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];<br />
[button addTarget:self action:@selector(targetMethod:) forControlEvents:UIControlEventTouchDown];<br />
[button setTitle:@"Show View" forState:UIControlStateNormal];<br />
button.frame = CGRectMake(0.0, 0.0, 160.0, 40.0);<br />
[self.view addSubview:button];</p>
<p>////////////////////////////////////////<br />
// Button with background images<br />
////////////////////////////////////////</p>
<p>UIButton *bttn = [UIButton buttonWithType:UIButtonTypeCustom];<br />
bttn.frame = CGRectMake(0, 200, 97, 38);<br />
[bttn setTitle:@"Dev One" forState:UIControlStateNormal];<br />
[bttn addTarget:self action:@selector(targetMethod:) forControlEvents:UIControlEventTouchUpInside];</p>
<p>UIImage *bttnImageNormal = [UIImage imageNamed:@"button.png"];<br />
[bttn setImage:bttnImageNormal forState:UIControlStateNormal];</p>
<p>UIImage *bttnImageSelected = [UIImage imageNamed:@"button-selected.png"];<br />
[bttn setImage:bttnImageSelected forState:UIControlStateHighlighted];</p>
<p>[self.view addSubview:bttn];</p>
<p>-(IBAction)targetMethod:(id)sender {</p>
<p>	NSLog(@&#8221;targetMethod&#8221;);</p>
<p>}</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesborder.com/2012/02/objective-c-uibutton/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective-C Remote Plist -&gt; Dictionary -&gt; NSUserDefaults</title>
		<link>http://jamesborder.com/2012/01/objective-c-remote-plist-dictionary-nsuserdefaults/</link>
		<comments>http://jamesborder.com/2012/01/objective-c-remote-plist-dictionary-nsuserdefaults/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 20:10:19 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[Objective-C]]></category>

		<guid isPermaLink="false">http://jamesborder.com/?p=974</guid>
		<description><![CDATA[#import &#60;Foundation/Foundation.h> @interface RemotePreferences : NSObject { NSMutableData *incomingData; } @end @implementation RemotePreferences -(id)init { self = [super init]; if (self) { NSURL *url = [NSURL URLWithString: @"http://example.com/configs.plist"]; NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30.0]; __unused NSURLConnection *fetchConn = [[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease]; } return self; } - (void)connection:(NSURLConnection *)sender didReceiveData:(NSData *)data { if <a href='http://jamesborder.com/2012/01/objective-c-remote-plist-dictionary-nsuserdefaults/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p><code>#import &lt;Foundation/Foundation.h></p>
<p>@interface RemotePreferences : NSObject {<br />
	NSMutableData *incomingData;<br />
}</p>
<p>@end</p>
<p>@implementation RemotePreferences</p>
<p>-(id)init {</p>
<p>    self = [super init];</p>
<p>    if (self) {</p>
<p>		NSURL *url = [NSURL URLWithString: @"http://example.com/configs.plist"];<br />
		NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30.0];<br />
		__unused NSURLConnection *fetchConn = [[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease];</p>
<p>    }</p>
<p>    return self;	</p>
<p>}</p>
<p>- (void)connection:(NSURLConnection *)sender didReceiveData:(NSData *)data {</p>
<p>	if (!incomingData) {<br />
		incomingData = [[NSMutableData alloc] init];<br />
	}</p>
<p>	[incomingData appendData:data];</p>
<p>}</p>
<p>- (void)connectionDidFinishLoading:(NSURLConnection *)sender {</p>
<p>	NSDictionary *prefsDict = [[[NSDictionary alloc] init] autorelease];<br />
	prefsDict = [NSPropertyListSerialization propertyListFromData:incomingData mutabilityOption:NSPropertyListImmutable format:nil errorDescription:nil];</p>
<p>	[[NSUserDefaults standardUserDefaults] registerDefaults:prefsDict];</p>
<p>	// NSLog(@"NSUserDefaults dump: %@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);</p>
<p>}</p>
<p>- (void)connection:(NSURLConnection *)sender didFailWithError:(NSError *)error {<br />
	NSLog(@"connection failed: %@", [error localizedDescription]);<br />
}</p>
<p>-(void)dealloc {<br />
	FuncLog();</p>
<p>    [super dealloc];</p>
<p>	[incomingData release];<br />
	incomingData = nil;</p>
<p>}</p>
<p>//- (NSURLRequest *)connection:(NSURLConnection *)c willSendRequest:(NSURLRequest *)req redirectResponse:(NSURLResponse *)res {}<br />
//- (void)connection:(NSURLConnection *)sender didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)ch {}<br />
//- (NSCachedURLResponse *)connection:(NSURLConnection *)sender willCacheResponse:(NSCachedURLResponse *)cachedResponse{}</p>
<p>@end<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://jamesborder.com/2012/01/objective-c-remote-plist-dictionary-nsuserdefaults/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective-C UITabBarController selecting a tab and calling viewDidAppear</title>
		<link>http://jamesborder.com/2011/12/objective-c-calling-viewdidappear-on-select-uitabbarcontroller/</link>
		<comments>http://jamesborder.com/2011/12/objective-c-calling-viewdidappear-on-select-uitabbarcontroller/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 16:09:11 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[IOS]]></category>
		<category><![CDATA[Objective-C]]></category>

		<guid isPermaLink="false">http://jamesborder.com/?p=942</guid>
		<description><![CDATA[self.tabBarController.selectedIndex = 3; [self.tabBarController.selectedViewController viewDidAppear:YES]; if inside a custom tabbarcontroller doing this //call viewWillDisappear in the current view [self.selectedViewController viewWillDisappear:YES]; //change view self.selectedIndex = tabID; //call viewDidAppear in the current view [self.selectedViewController viewDidAppear:YES];]]></description>
			<content:encoded><![CDATA[<p>self.tabBarController.selectedIndex = 3;<br />
[self.tabBarController.selectedViewController viewDidAppear:YES];</p>
<p>if inside a custom tabbarcontroller doing this</p>
<p>//call viewWillDisappear in the current view<br />
[self.selectedViewController viewWillDisappear:YES];</p>
<p>//change view<br />
 self.selectedIndex = tabID;</p>
<p>//call viewDidAppear in the current view<br />
[self.selectedViewController viewDidAppear:YES];</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesborder.com/2011/12/objective-c-calling-viewdidappear-on-select-uitabbarcontroller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert seconds (like timestamp) to DD:HH:MM:SS</title>
		<link>http://jamesborder.com/2011/11/convert-seconds-like-timestamp-to-ddhhmmss/</link>
		<comments>http://jamesborder.com/2011/11/convert-seconds-like-timestamp-to-ddhhmmss/#comments</comments>
		<pubDate>Wed, 09 Nov 2011 04:08:55 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[Objective-C]]></category>

		<guid isPermaLink="false">http://jamesborder.com/?p=932</guid>
		<description><![CDATA[Was not written to be used on a real timestamp, was written to be used counting up from 0. int tmp = secondCount; int _Days = tmp / (60 * 60 * 24); tmp -= _Days * (60 * 60 * 24); int _Hrs = tmp / (60 * 60); tmp -= _Hrs * (60 <a href='http://jamesborder.com/2011/11/convert-seconds-like-timestamp-to-ddhhmmss/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Was not written to be used on a real timestamp, was written to be used counting up from 0.</p>
<p>			int tmp = secondCount;</p>
<p>			int _Days = tmp / (60 * 60 * 24);<br />
			tmp -= _Days * (60 * 60 * 24);<br />
			int _Hrs = tmp / (60 * 60);<br />
			tmp -= _Hrs * (60 * 60);<br />
			int _Min = tmp / 60;<br />
			tmp -= _Min * 60;<br />
			int _Sec = tmp;</p>
<p>			NSString *displayString = [NSString stringWithFormat:@"%02i:%02i:%02i:%02i", _Days, _Hrs, _Min, _Sec];</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesborder.com/2011/11/convert-seconds-like-timestamp-to-ddhhmmss/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective-c Call Javascript Functions in nested webviews</title>
		<link>http://jamesborder.com/2011/09/objective-c-call-javascript-functions-in-nested-webviews/</link>
		<comments>http://jamesborder.com/2011/09/objective-c-call-javascript-functions-in-nested-webviews/#comments</comments>
		<pubDate>Sun, 25 Sep 2011 17:21:34 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[IOS]]></category>
		<category><![CDATA[Objective-C]]></category>

		<guid isPermaLink="false">http://jamesborder.com/?p=920</guid>
		<description><![CDATA[-(void)callJavascriptFunctionInAllWebViews { if ([[scrollView subviews] count] > 0) { for (UIWebView *subWebView in [scrollView subviews]) { NSString *jsCommand = [NSString stringWithFormat:@"whateverJSFunction();"]; [subWebView stringByEvaluatingJavaScriptFromString:jsCommand]; } } }]]></description>
			<content:encoded><![CDATA[<p>-(void)callJavascriptFunctionInAllWebViews {	</p>
<p>	if ([[scrollView subviews] count] > 0) {</p>
<p>		for (UIWebView *subWebView in [scrollView subviews]) {<br />
			NSString *jsCommand = [NSString stringWithFormat:@"whateverJSFunction();"];<br />
			[subWebView stringByEvaluatingJavaScriptFromString:jsCommand];<br />
		}</p>
<p>	}</p>
<p>}</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesborder.com/2011/09/objective-c-call-javascript-functions-in-nested-webviews/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create some file and directory if they don&#8217;t exist</title>
		<link>http://jamesborder.com/2011/09/create-some-file-and-directory-if-they-dont-exist/</link>
		<comments>http://jamesborder.com/2011/09/create-some-file-and-directory-if-they-dont-exist/#comments</comments>
		<pubDate>Tue, 06 Sep 2011 20:06:09 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[IOS]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jamesborder.com/?p=950</guid>
		<description><![CDATA[BOOL didItWork = [self createDirAndFile:@"index.html" inDir:@"somedirectory"]; NSLog(@&#8221;WAS FILE CREATED? %i&#8221;, didItWork); // methods used -(BOOL)createDirAndFile:(NSString*)fileName inDir:(NSString*)dir { NSString *str = @&#8221;whatever needs to be in the file when created&#8221;; NSData *data=[str dataUsingEncoding:NSUTF8StringEncoding]; NSFileManager *filemgr = [NSFileManager defaultManager]; NSString *documentsDirectoryPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSLog(@&#8221; documentsDirectoryPath = %@&#8221;, documentsDirectoryPath); NSString *targetDir = [documentsDirectoryPath stringByAppendingPathComponent:dir]; NSLog(@&#8221; <a href='http://jamesborder.com/2011/09/create-some-file-and-directory-if-they-dont-exist/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>	BOOL didItWork = [self createDirAndFile:@"index.html" inDir:@"somedirectory"];<br />
	NSLog(@&#8221;WAS FILE CREATED? %i&#8221;, didItWork);</p>
<p>// methods used</p>
<p>-(BOOL)createDirAndFile:(NSString*)fileName inDir:(NSString*)dir {</p>
<p>	NSString *str = @&#8221;whatever needs to be in the file when created&#8221;;<br />
	NSData *data=[str dataUsingEncoding:NSUTF8StringEncoding];</p>
<p>	NSFileManager *filemgr = [NSFileManager defaultManager];</p>
<p>	NSString *documentsDirectoryPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];<br />
	NSLog(@&#8221; documentsDirectoryPath = %@&#8221;, documentsDirectoryPath);</p>
<p>	NSString *targetDir = [documentsDirectoryPath stringByAppendingPathComponent:dir];<br />
	NSLog(@&#8221; targetDir = %@&#8221;, targetDir);</p>
<p>	NSString *targetFile = [targetDir stringByAppendingPathComponent:fileName];<br />
	NSLog(@&#8221; targetFile = %@&#8221;, targetFile);</p>
<p>	BOOL isDir;</p>
<p>    if (![filemgr fileExistsAtPath:targetDir isDirectory:&#038;isDir]) {</p>
<p>		NSLog(@&#8221;Directory did not exist so create it&#8221;);<br />
		[filemgr createDirectoryAtPath:targetDir withIntermediateDirectories:NO attributes:nil error:nil];</p>
<p>		NSLog(@&#8221;If the target directory did not exist the file we are creating certainly did not exist so create it&#8221;);<br />
		return [self createMyFile:targetFile contents:data];</p>
<p>	} else {</p>
<p>		return [self createMyFile:targetFile contents:data];</p>
<p>	}</p>
<p>}</p>
<p>-(BOOL) createMyFile:(NSString*)desiredFile contents:(NSData*)fileContents {</p>
<p>	if ( ![[NSFileManager defaultManager] fileExistsAtPath:desiredFile] ) {</p>
<p>		[[NSFileManager defaultManager] createFileAtPath:desiredFile contents:fileContents attributes:nil];<br />
		return YES;</p>
<p>	}</p>
<p>	return NO;</p>
<p>}</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesborder.com/2011/09/create-some-file-and-directory-if-they-dont-exist/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective-C create some file if it doesn&#8217;t exist</title>
		<link>http://jamesborder.com/2011/09/objective-c-create-some-file-if-it-doesnt-exist/</link>
		<comments>http://jamesborder.com/2011/09/objective-c-create-some-file-if-it-doesnt-exist/#comments</comments>
		<pubDate>Tue, 06 Sep 2011 16:56:36 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[IOS]]></category>
		<category><![CDATA[Objective-C]]></category>

		<guid isPermaLink="false">http://jamesborder.com/?p=899</guid>
		<description><![CDATA[-(void)createHtmlFileIfMissing:(NSString*)fileName inDir:(NSString*)dir { NSString *str= @&#8221;whatever needs to be there to start&#8221;; NSData *data=[str dataUsingEncoding:NSUTF8StringEncoding]; NSFileManager *filemgr = [NSFileManager defaultManager]; NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *targetDir = [documentsPath stringByAppendingPathComponent:dir]; NSString *targetFile = [targetDir stringByAppendingPathComponent:fileName]; BOOL targetFileExists = [[NSFileManager defaultManager] fileExistsAtPath:targetFile]; if (!targetFileExists ) { [filemgr createFileAtPath:targetFile contents:data attributes:nil]; } }]]></description>
			<content:encoded><![CDATA[<p>-(void)createHtmlFileIfMissing:(NSString*)fileName inDir:(NSString*)dir  {</p>
<p>	NSString *str= @&#8221;whatever needs to be there to start&#8221;;<br />
	NSData *data=[str dataUsingEncoding:NSUTF8StringEncoding];</p>
<p>	NSFileManager *filemgr = [NSFileManager defaultManager];<br />
	NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];</p>
<p>	NSString *targetDir = [documentsPath stringByAppendingPathComponent:dir];<br />
	NSString *targetFile = [targetDir stringByAppendingPathComponent:fileName];<br />
	BOOL targetFileExists = [[NSFileManager defaultManager] fileExistsAtPath:targetFile];</p>
<p>	if (!targetFileExists ) {<br />
		[filemgr createFileAtPath:targetFile contents:data attributes:nil];<br />
	} </p>
<p>}</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesborder.com/2011/09/objective-c-create-some-file-if-it-doesnt-exist/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

