• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: issues encoding MailMessage and NSData
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: issues encoding MailMessage and NSData


  • Subject: Re: issues encoding MailMessage and NSData
  • From: Reza Farhad <email@hidden>
  • Date: Fri, 22 May 2009 14:58:59 +0100

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 (email@hidden)

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:
This email sent to email@hidden


References: 
 >issues encoding MailMessage and NSData (From: Reza Farhad <email@hidden>)

  • Prev by Date: Re: [iPhone] Any way to animate a tab-bar away?
  • Next by Date: Load tabbarcontroller without UIwindow
  • Previous by thread: Re: issues encoding MailMessage and NSData
  • Next by thread: [iPhone] Any way to animate a tab-bar away?
  • Index(es):
    • Date
    • Thread