Amazon.com Widgets Ex 16-4. My answer
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 24, 2013, 09:10:26 AM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Old Stuff
| |-+  Answers to Exercises
| | |-+  Chapter 16 (Moderator: sgg_admin)
| | | |-+  Ex 16-4. My answer
Pages: [1]   Go Down
Print
Author Topic: Ex 16-4. My answer  (Read 307 times)
Nick Harvey
Newbie
*
Posts: 19






« on: June 07, 2012, 11:32:06 PM »

I have written this in XCode which is slightly different to using command line.

NSString+TempFiles.h

#import <Foundation/Foundation.h>

@interface NSString (TempFiles)

+(NSString *) temporaryFileName;

@end

NSString+TempFiles.m

#import "NSString+TempFiles.h"

@implementation NSString (TempFiles)

+(NSString *) temporaryFileName
{
  NSProcessInfo *proc = [NSProcessInfo processInfo];
  return [proc globallyUniqueString];
}

@end

main.m
#import "NSString+TempFiles.h"

int main (int argc, const char * argv[])
{
  @autoreleasepool
  {
    for (int i = 1; i <= 10; i++) {
      NSLog(@"Temp file name %i = %@", i, [NSString temporaryFileName]);
    }
  }
    return 0;
}
Logged
Pages: [1]   Go Up
Print
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.