Re: Files can't be saved to the relative paths?
Re: Files can't be saved to the relative paths?
- Subject: Re: Files can't be saved to the relative paths?
- From: Henry McGilton <email@hidden>
- Date: Sat, 18 Aug 2007 21:20:51 -0700
On Aug 19, 2007, at 3:51 AM, Steve wrote:
Hi Everyone.
What I want to do is capture some pictures of the movie, then save
them to the current desktop. Then I use the code following:
NSImage * currentFrameImage = [movie currentFrameImage];
// get current frame presented by NSImage
NSData * tiffData = [currentFrameImage TIFFRepresentation];
//get the tiff Data from the NSImage
NSCalendarDate * newCalendarDate = [NSCalendarDate calendarDate];
[newCalendarDate setCalendarFormat:@"%Y%m%d%H%M%S"];
NSString * fileName = [NSString stringWithFormat:@"%@-%@.tiff",
[[globalPath lastPathComponent] stringByDeletingPathExtension],
[newCalendarDate description]];
//NSLog(fileName);
//The following path is the issue.
NSString * folderPath = @"/";
//
NSString * resultString = [folderPath
stringByAppendingPathComponent:fileName];
NSLog(resultString);
if ([tiffData writeToFile:resultString atomically:YES] ) {
printf("Image Saved\n");
}
I used the folderPath variable to present the path. However , if I
wrote
code like these: folderPath = @"$HOME/Desktop", the tiffDate
writeToFile function never works. I don't know why, perhaps you
have to write to absolute path?
Looks like you expect NSString to resolve $HOME for you.
Tell us why you expect this behaviour from NSString.
Look at NSHomeDirectory and NSHomeDirectoryForUser
in Foundation Functions. Also look at the NSString method
stringByExpandingTildeInPath.
And after that, look into the Cocoa documentation for the topic:
'Introduction to Low-Level File Management Programming Topics'
Cheers,
........ Henry
===============================+============================
Henry McGilton, Boulevardier | Trilithon Software
Objective-C/Java Composer | Seroia Research
-------------------------------+----------------------------
mailto:email@hidden | http://www.trilithon.com
|
===============================+============================
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden