I have solved the issue PARTLY.

My NSData issue seems to have been resolved, and that was my mistake so I will no go into it.

Now it appears that I can convert the MailMessage to NSData and save the data and read the data on startup. However if I try to convert this Data to a MailMessage as the data is being initialized by calling:

[ NSKeyedUnarchiver unarchiveObjectWithData:messageData ]

I get the error. Could this be due to the Mail calls not haven't been loaded?

Now if I save the data and try to do the conversation at runtime then I dont get the error, but the pointer to the MailMessage that I get back does not seem to be the original pointer that I had saved. If I try a test and at the time that I read the MailMessage, convert it to an NSData and then immediately convert it back it works fine, however if I try it in another call even without restarting the app I get a different MailMessage data.

This is the descriptor that I get when I first create and convert the MailMessage

<MailMessage @0x1a800510: <class 'mssg'> id 36371 of <class 'mbxp'> "INBOX" of <class 'mact'> ".Mac" of application "Mail" (15594)>

and this is the descriptor when I try it from another call

<MailMessage @0x63b4e0: application "Mail" (15594)>

Any help!!!

Thanks

Reza


On 22 May 2009, at 11:31, Reza Farhad wrote:

Hi all

I am trying to save a MailMessage that I obtain from Apple Mail using scripting bridge.

I get the message and I check to see if it does conform to NSCoding protocols, which it does.

[ message conformsToProtocol:@protocol(NSCoding)]

then I go to encode it in my encodeWithCoder call

- (void)encodeWithCoder:(NSCoder *)encoder
{
        [ encoder encodeObject:message forKey:@"message" ];
}


that works fine, but when I go to decode the object I get the following error:

exception raised:*** -decodeObjectForKey: only defined for abstract class. Define -[NSKeyedArchiver decodeObjectForKey:]!

I even tried to convert the message object to NSData and then encode it:

- (void)encodeWithCoder:(NSCoder *)encoder
{
NSData *data = [ NSKeyedArchiver archivedDataWithRootObject:message ];
        [ encoder encodeObject:data forKey:@"message" ];
}

however still I get the same error when trying to decode the data

        NSData *returnData = [ encoder decodeObjectForKey:@"message" ];

Thanks




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to