Help : making of plugin for aladdin

Any trouble you encounter with the Pedias, here's the place to ask for help.
Post Reply
djhan
Addicted to Bruji
Addicted to Bruji
Posts: 27
Joined: Tue Nov 28, 2006 8:55 pm

Help : making of plugin for aladdin

Post by djhan »

Hello, I'm DJ.HAN.

I have a problem with aladdin (korean biggest online bookstore : http://www.aladdin.co.kr ) plugin in bookpedia 4.5.3 in Snow Leopard.
a few days ago, aladdin site was reformed. They changed HTML tags. So I start rebuild plugin.

But well..... problem is releaseDate.

I got released date from aladdin site using with following source

Code: Select all

	NSString *releaseDate = [temp_info stringBetween:@"</a> | " and:@"</td></tr>"];
	if (releaseDate) 
		[returnData setObject:releaseDate forKey:@"releaseDate"];
In this time, aladdin was display release date as YYYY-MM-DD: eg) 2009-09-01

But Bookpedia 4.5.3 cannot accept this format !! It can only accept DD-MM-YYYY format : eg)01-09-2009.
So I failed input released date in aladdin plugin.

How can I change format YYYY-MM-DD to DD-MM-YYYY ?
or, do you have a development plan of various date format in bookpedia?

Please help me.
Thanks, good luck
bobino
Addicted to Bruji
Addicted to Bruji
Posts: 47
Joined: Tue May 26, 2009 4:23 pm

Re: Help : making of plugin for aladdin

Post by bobino »

Hi,

return a NSDate instead of a NSString and format it yourself:

Code: Select all

NSString *releaseDate = [temp_info stringBetween:@"</a> | " and:@"</td></tr>"];
 if (releaseDate) 
  NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
  [inputFormatter setDateFormat:@"MM/yyyy"];		//change the format for your need
  NSDate *dateForKey = [inputFormatter dateFromString: releaseDate];
  [returnData setObject:dateForKey forKey:@"releaseDate"];
User avatar
Conor
Top Dog
Posts: 5345
Joined: Sat Jul 03, 2004 12:58 pm
Contact:

Re: Help : making of plugin for aladdin

Post by Conor »

Hi DJ. Han,

Bombino is correct. The only thing I would change would be the last line from:

Code: Select all

[returnData setObject:dateForKey forKey:@"releaseDate"];
to:

Code: Select all

[returnData setValue:dateForKey forKey:@"releaseDate"];
The "Key Value Coding" method can take a nil object, the setObject: method will raise an exception if your formatter happens to not parse the date and returns nil. Also add the missing but implied (by indentation) curly brackets for the if statement and don't forget to release the date formatter. So to put it all together it would be:

Code: Select all

NSString *releaseDate = [temp_info stringBetween:@"</a> | " and:@"</td></tr>"];
if (releaseDate) {
  NSDateFormatter *inputFormatter = [[[NSDateFormatter alloc] init] autorelease];
  [inputFormatter setDateFormat:@"yyyy-MM-dd"];
  NSDate *dateForKey = [inputFormatter dateFromString: releaseDate];
  [returnData setValue:dateForKey forKey:@"releaseDate"];
}
djhan
Addicted to Bruji
Addicted to Bruji
Posts: 27
Joined: Tue Nov 28, 2006 8:55 pm

Re: Help : making of plugin for aladdin

Post by djhan »

Thanks for your support. I succeed build new aladdin plugin.

Thanks, thanks bobino & conor. Thanks!!!!
Post Reply