plugin menuCommandFor issue

Any trouble you encounter with the Pedias, here's the place to ask for help.
User avatar
Conor
Top Dog
Posts: 5346
Joined: Sat Jul 03, 2004 12:58 pm
Contact:

Re: plugin menuCommandFor issue

Post by Conor »

I overlooked the mistake as I am used to programming directly with the inner relationships that as you found out by looking at the NSManagedObject is called "linksSet" but the add function takes only a "links" array that goes through validation before being added. So change @"linksSet" to @"links".
bobino
Addicted to Bruji
Addicted to Bruji
Posts: 47
Joined: Tue May 26, 2009 4:23 pm

Re: plugin menuCommandFor issue

Post by bobino »

hi,
only the first dictionary of the array is reccorded .
is it a bug ?
User avatar
Conor
Top Dog
Posts: 5346
Joined: Sat Jul 03, 2004 12:58 pm
Contact:

Re: plugin menuCommandFor issue

Post by Conor »

Can you please send me your code, you might be replacing one NSArray with another? The following works:

Code: Select all

NSMutableArray *arrayURL =[NSMutableArray array];
	[secondItem setObject:arrayURL forKey:@"links"];
	
    NSMutableDictionary * anotherURL =[NSMutableDictionary dictionaryWithCapacity:3];
	[anotherURL setObject:@"http://www.tests/" forKey:@"url"];
	[anotherURL setObject:@"urlName" forKey:@"name"];
	[anotherURL setObject:@"urlType" forKey:@"type"];
	[arrayURL addObject:anotherURL];
	
	NSMutableDictionary *anotherURL2 =[NSMutableDictionary dictionaryWithCapacity:3];
	[anotherURL2 setObject:@"http://www.tests2.com/" forKey:@"url"];
	[anotherURL2 setObject:@"two" forKey:@"name"];
	[anotherURL2 setObject:@"two" forKey:@"type"];
	[arrayURL addObject:anotherURL2];
bobino
Addicted to Bruji
Addicted to Bruji
Posts: 47
Joined: Tue May 26, 2009 4:23 pm

Re: plugin menuCommandFor issue

Post by bobino »

i try exactly the following code

Code: Select all

	 
NSMutableArray *arrayURL =[NSMutableArray array];
		NSMutableDictionary * anotherURL =[NSMutableDictionary dictionaryWithCapacity:3];
		[anotherURL setObject:@"http://www.tests/" forKey:@"url"];
		[anotherURL setObject:@"urlName" forKey:@"name"];
		[anotherURL setObject:@"urlType" forKey:@"type"];
		[arrayURL addObject:anotherURL];
		
		NSMutableDictionary *anotherURL2 =[NSMutableDictionary dictionaryWithCapacity:3];
		[anotherURL2 setObject:@"http://www.tests2.com/" forKey:@"url"];
		[anotherURL2 setObject:@"two" forKey:@"name"];
		[anotherURL2 setObject:@"two" forKey:@"type"];
		[arrayURL addObject:anotherURL2];
		
		[returnData setObject:arrayURL forKey:@"links"];
only the first item is reccorded
User avatar
Conor
Top Dog
Posts: 5346
Joined: Sat Jul 03, 2004 12:58 pm
Contact:

Re: plugin menuCommandFor issue

Post by Conor »

Strange. I have uploaded another beta just for precautions that we have the latest version and try this entire function as a test that works for me:

Code: Select all

- (NSArray *)menuCommandFor:(NSArray *)selectedObjects {
	NSMutableDictionary *firstItem = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"A Book", @"title", @"An Author", @"author", nil];
	NSMutableDictionary *secondItem = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"Another Book", @"title", @"Another Autor", @"author", @"n Editor", @"editor", @"http://www.bruji.com/dvdpedia/images/mainScreenshot.png", @"imageLocation", nil];
	
	NSMutableArray *arrayURL =[NSMutableArray array];
	NSMutableDictionary * anotherURL =[NSMutableDictionary dictionaryWithCapacity:3];
	[anotherURL setObject:@"http://www.tests/" forKey:@"url"];
	[anotherURL setObject:@"urlName" forKey:@"name"];
	[anotherURL setObject:@"urlType" forKey:@"type"];
	[arrayURL addObject:anotherURL];
	
	NSMutableDictionary *anotherURL2 =[NSMutableDictionary dictionaryWithCapacity:3];
	[anotherURL2 setObject:@"http://www.tests2.com/" forKey:@"url"];
	[anotherURL2 setObject:@"two" forKey:@"name"];
	[anotherURL2 setObject:@"two" forKey:@"type"];
	[arrayURL addObject:anotherURL2];
	
	[firstItem setObject:arrayURL forKey:@"links"];
	
	return [NSArray arrayWithObjects:firstItem, secondItem, nil];
}
bobino
Addicted to Bruji
Addicted to Bruji
Posts: 47
Joined: Tue May 26, 2009 4:23 pm

Re: plugin menuCommandFor issue

Post by bobino »

i will test your code this evening.
the only difference i see with my test is that i tested it with the (NSDictionary *)resultNumber method called by th searchfor method. I imagine i use the same code for both.
User avatar
Conor
Top Dog
Posts: 5346
Joined: Sat Jul 03, 2004 12:58 pm
Contact:

Re: plugin menuCommandFor issue

Post by Conor »

Thank you for clearing that up, I have fixed the bug an "if" instead of a "while" for enumerating, here is the latest beta.
bobino
Addicted to Bruji
Addicted to Bruji
Posts: 47
Joined: Tue May 26, 2009 4:23 pm

Re: plugin menuCommandFor issue

Post by bobino »

Hi,

Thks Conor, the last beta is perfect.

Is there programmatically a way to add en entry to the wishlist if the user didn't select it before ?
User avatar
Conor
Top Dog
Posts: 5346
Joined: Sat Jul 03, 2004 12:58 pm
Contact:

Re: plugin menuCommandFor issue

Post by Conor »

No way to add it to another collection but the selected collection, I'll look at expanding the plug-in interface to include that possibility for you.
bobino
Addicted to Bruji
Addicted to Bruji
Posts: 47
Joined: Tue May 26, 2009 4:23 pm

Re: plugin menuCommandFor issue

Post by bobino »

Hi Conor,

i test to add 1500 books with covers using the plugin method MenuCommandFor. Covers are localy on my HDD.
Bookpedia is going out of memory and crash. It seems that memory allocated to copy covers is not released during your adding process.
Last edited by bobino on Wed Jul 29, 2009 9:29 am, edited 1 time in total.
User avatar
Conor
Top Dog
Posts: 5346
Joined: Sat Jul 03, 2004 12:58 pm
Contact:

Re: plugin menuCommandFor issue

Post by Conor »

I have added an auto release pool around the code to free memory on the go, let me know if you still have problems with large numbers.
bobino
Addicted to Bruji
Addicted to Bruji
Posts: 47
Joined: Tue May 26, 2009 4:23 pm

Re: plugin menuCommandFor issue

Post by bobino »

hi,
when i add a book through the plugin with values for fields "borrowedBy", "borrowedOn" and "dueDate", the book doesn't appear in the borrowed list. What do i need to do for that ?
thks
User avatar
Conor
Top Dog
Posts: 5346
Joined: Sat Jul 03, 2004 12:58 pm
Contact:

Re: plugin menuCommandFor issue

Post by Conor »

I have updated the beta to add a book into the borrowed collection when a "borrowedBy" value is set.
bobino
Addicted to Bruji
Addicted to Bruji
Posts: 47
Joined: Tue May 26, 2009 4:23 pm

Re: plugin menuCommandFor issue

Post by bobino »

Conor wrote:No way to add it to another collection but the selected collection, I'll look at expanding the plug-in interface to include that possibility for you.
i Conor, any news about that point ? this will be very very usefull ....

thks
User avatar
Conor
Top Dog
Posts: 5346
Joined: Sat Jul 03, 2004 12:58 pm
Contact:

Re: plugin menuCommandFor issue

Post by Conor »

I have added the following methods in the beta. Use the following code to get the collections and then select the correct one before adding your entries:

Code: Select all

MyCollectionTableView *collections = [[NSApp delegate] getCollections];
You can then get relevant collections with the following methods (already encased in an interface declaration so you can add them to the MyControllerForPlugins.h header file):

Code: Select all

// Application Controller 
@interface MyCollectionTableView : NSObject
- (MOCollection *)selectedCollection;
- (MOCollection *)borrowedCollection;
- (MOCollection *)wishlistCollection;
- (MOCollection *)libraryCollection;
- (NSArray *)allCollections;

// To select a collection use:

- (void)selectCollection:(MOCollection *)aCollection;
@end
You will also need to add the getCollections method to the existing Controller interface declaration:

Code: Select all

// Application Controller 
@interface MyControllerForPlugins : NSObject
- (MyCollectionTableView *)getCollections;
Post Reply