Hi group
I'm new to Cocoa and Objective-C. Not to programming though.
I'm trying to get/set an image from file (and core) data.
If i use the opendialog it dosent work.....
_txtFileName is a textfield linked to core data.
But if i "hard code" it works...
What am i doing wrong ?
I'm new to Cocoa and Objective-C. Not to programming though.
I'm trying to get/set an image from file (and core) data.
If i use the opendialog it dosent work.....
Code:
for( i = 0; i < [files count]; i++ )
{
NSString* fileName = [files objectAtIndex:i];
// Do something with the filename.
[_txtFileName setStringValue:fileName];
}
NSImage *tempImage = [[NSImage alloc] initWithContentsOfFile:[_txtFileName stringValue]];
// set the image in the image view
if (tempImage != nil){
NSLog(@"Picture found");
[_imageVi setImage: tempImage];
}
else
NSLog(@"Ingen billede");
}
}
_txtFileName is a textfield linked to core data.
But if i "hard code" it works...
Code:
- (IBAction)changepicture:(id)sender {
NSImage *tempImage = [[NSImage alloc] initWithContentsOfFile:@"/Users/Hansen/Pictures/Apple.jpg"];
// set the image in the image view
if (tempImage != nil){
NSLog(@"Picture found");
[_imageVi setImage: tempImage];
}
}
Last edited by a moderator: