Radio and PodcastRadio and PodcastLive Radio & Podcasts
Cocoa Maker 5 - File Management artwork
Technology

Cocoa Maker 5 - File Management

Cocoa Maker by Mr. Gecko

Mar 20, 2010Technology

James ( MrGeckosMedia.com ), joined by, Noah ( RockntheSweater.com ), and Karl, explains how file managing works in c and cocoa. 7:49 Example code from episode. Files C Example <Foundation/Foundation.h> BOOL file_e...

About This Episode

Cocoa Maker 5 - File Management is an episode from Cocoa Maker by Mr. Gecko. James ( MrGeckosMedia.com ), joined by, Noah ( RockntheSweater.com ), and Karl, explains how file managing works in c and cocoa. 7:49 Example code from episode. Fi...

Podcast

This episode belongs to Cocoa Maker.

Listen Online

Use the player on this page to stream the episode online.

Episode Details

Published Mar 20, 2010, audio available.

Questions About This Episode

What is Cocoa Maker 5 - File Management about?

James ( MrGeckosMedia.com ), joined by, Noah ( RockntheSweater.com ), and Karl, explains how file managing works in c and cocoa. 7:49 Example code from episode. Files C Example <Foundation/Foundation.h> BOOL file_exist(const char *fileName) { FILE *file = fopen(fileName, "r"); if (file) { fclose(file); return YES; } return NO; } int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; const char *ourFile = [[@"~/Desktop/file.txt" stringByExpandingTildeInPath] UTF8String]; FILE *file; if (!file_exist(ourFile)) { file = fopen(ourFile, "w"); time_t currTime = time(NULL); fprintf(file, "%s: We just made this file.\n", ctime(&currTime)); } else { file = fopen(ourFile, "a"); } time_t currTime = time(NULL); fprintf(file, "%s: Here is a new line in this file.\n", ctime(&currTime)); fclose(file); [pool drain]; return 0; } Files Cocoa Exmaple <Foundation/Foundation.h> int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSFileManager *manager = [NSFileManager defaultManager]; NSString *ourFile = [@"~/Desktop/file.txt" stringByExpandingTildeInPath]; NSFileHandle *file; if (![manager fileExistsAtPath:ourFile]) { [manager createFileAtPath:ourFile contents:nil attributes:nil]; file = [NSFileHandle fileHandleForWritingAtPath:ourFile]; [file writeData:[[NSString stringWithFormat:@"%@: Here is a new file.\n", [NSDate date]] dataUsingEncoding:NSUTF8StringEncoding]]; } else { file = [NSFileHandle fileHandleForWritingAtPath:ourFile]; [file seekToEndOfFile]; } [file writeData:[[NSString stringWithFormat:@"%@: Here is a new line.\n", [NSDate date]] dataUsingEncoding:NSUTF8StringEncoding]]; [file closeFile]; [pool drain]; return 0; } Keynote used in this Episode Keynote in PDF Format

Where can I listen to Cocoa Maker 5 - File Management?

You can listen to Cocoa Maker 5 - File Management online on Radio and Podcast. Open the player on this page to stream the available audio.

Which podcast is Cocoa Maker 5 - File Management from?

Cocoa Maker 5 - File Management is an episode from Cocoa Maker by Mr. Gecko.

How long is this episode?

The episode duration depends on the source podcast feed and may not always be available.

When was this episode published?

This episode was published on Mar 20, 2010.

Can I save Cocoa Maker 5 - File Management for later?

Yes. Use the heart button on the episode page to add it to your favorite episodes list.

Are there related episodes from Cocoa Maker?

Yes. This page shows related episodes from Cocoa Maker when more episodes are available from the podcast feed.

Quick Answers About This Episode

Where can I listen to Cocoa Maker 5 - File Management?

You can listen to Cocoa Maker 5 - File Management on this page when the episode audio is available from the podcast feed.

Which podcast is this episode from?

Cocoa Maker 5 - File Management is from Cocoa Maker by Mr. Gecko.

What are the episode details?

Published Mar 20, 2010