TEchnical Cites

  • 04:57:50 am on August 11, 2009 | 0
    Tags:

    NSString *tempFileTemplate =
    [NSTemporaryDirectory() stringByAppendingPathComponent:@”myapptempfile.XXXXXX”];
    const char *tempFileTemplateCString =
    [tempFileTemplate fileSystemRepresentation];
    char *tempFileNameCString = (char *)malloc(strlen(tempFileTemplateCString) + 1);
    strcpy(tempFileNameCString, tempFileTemplateCString);
    int fileDescriptor = mkstemp(tempFileNameCString);

    if (fileDescriptor == -1)
    {
    // handle file creation failure
    }

    // This is the file name if you need to access the file by name, otherwise you can remove
    // this line.
    tempFileName =
    [NSString
    stringWithFileSystemRepresentation:tempFileNameCString
    length:strlen(tempFileNameCString)];

    free(tempFileNameCString);
    tempFileHandle =
    [[NSFileHandle alloc]
    initWithFileDescriptor:fileDescriptor
    closeOnDealloc:NO];

    Advertisements
     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: