Newbie: Getting path of file dragged onto NSImageView
Newbie: Getting path of file dragged onto NSImageView
- Subject: Newbie: Getting path of file dragged onto NSImageView
- From: Sabin Densmore <email@hidden>
- Date: Wed, 9 Apr 2003 08:03:32 -0400
Hey all --
It's been a week of searching, to no avail. I need to find someway of
getting the path of an image that a user has dragged on to NSImageView
in this little app I'm writing. I need the path so I can run this
little beauty:
@implementation IVImageView
- (void)showImageDetails
{
[imageHeight setStringValue:[NSString
stringWithFormat:@"%d",(int)([image size].height)]];
[imageWidth setStringValue:[NSString
stringWithFormat:@"%d",(int)([image size].width)]];
filePath = @"/tmp"; //this isn't right, for some reason.
NSDictionary *fattrs = [[NSFileManager defaultManager]
fileAttributesAtPath:filePath traverseLink:NO];
fsize = [fattrs objectForKey:NSFileSize];
//NSLog(@"File Size: %d\n", [fsize intValue]);
[imageWeight setStringValue:[NSString
stringWithFormat:@"%d",[filePath lastPathComponent], [fsize intValue]]];
/*
[imageWeight setStringValue:[NSString
stringWithFormat:@"%d",[filePath lastPathComponent], [[[[NSFileManager
defaultManager] fileAttributesAtPath:filePath traverseLink:NO]
objectForKey:NSFileSize] stringValue]]]; */
}
- (IBAction)sendNewImage:(id)sender
{
image = [sender image];
[self showImageDetails];
}
- (void)dealloc
{
[super dealloc];
}
@end
I do get the heigh, width, and the file size of something displayed to
me, but I don't think it's the image. Any hints? Though I've learned a
lot about NSFileManager and its ways, how I can make it work with
NSImageView remains a mystery.
sabin
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.