Question about field modification with menucommandfor metho

Any trouble you encounter with the Pedias, here's the place to ask for help.
Post Reply
bobino
Addicted to Bruji
Addicted to Bruji
Posts: 47
Joined: Tue May 26, 2009 4:23 pm

Question about field modification with menucommandfor metho

Post by bobino »

hi,

i'm writting a menu Plugin in order to update fields, i have difficulties with 2 fields :

1/
releaseDate : I can't read de value for the key : the value is always empty (not nil), and i got an error if a try to change it:
NSString *oldValueForKey = [[entries objectAtIndex:i] objectForKey:@"releaseDate"]; // is always empty
[[entries objectAtIndex:i] setValue:newValueForKey forKey:@"releaseDate]; // the program crash

2/
I don't understand how is it possible to change the image cover, of course i read your explanation
"setImagePath: sends the path location of images in case your menuCommand works with images. You must retain this value to use in your menuCommandFor: method.

The NSDictionaries contain a value called "Image" that contains the name of the image file located in this folder for that particular entry. This file may contain a blank gif image of 1x1."

but: the key "Image" doesn't existe for the NSMutableDictionary entries
and i don't really understand how i have to use setImagePath: :-)

Could you provide me an example about how change the cover, it will be great !

Thanks for all !
User avatar
Conor
Top Dog
Posts: 5345
Joined: Sat Jul 03, 2004 12:58 pm
Contact:

Re: Question about field modification with menucommandfor metho

Post by Conor »

The "releaseDate" is a NSDate type object, when changing it be sure to set it as a NSDate object as well, you can use an NSDateFormatter dateFromString: if you need to translate from a string.

Code: Select all

NSDate *oldValueForKey = [[entries objectAtIndex:i] objectForKey:@"releaseDate"];
NSLog(@"%@", oldValueForKey);
The image part is my fault I need to update those methods. But use the "uid" for the entry and look in the Covers folder to identify or change the image. (The image path function is actually not relevant any more. Use the following:)

Code: Select all

NSString *imagePath = [@"~/Library/Application Support/Covers" stringByExpandingTildeInPath];  // This would be the default location
NSString *entryUID = [[entries objectAtIndex:i] objectForKey:@"uid"];
NSString *localImagePath = [NSString stringWithFormat:@"%@/Covers/%d.jpg", imagePath, [entryUID intValue]];

// Updating the cover from a NSImage called coverImage
[[[NSBitmapImageRep imageRepWithData:[coverImage TIFFRepresentation]] representationUsingType:NSJPEGFileType properties:[NSDictionary dictionaryWithObject:[NSDecimalNumber numberWithFloat:1.0] forKey:NSImageCompressionFactor]] writeToFile:localImagePath atomically:NO];

Post Reply