Objective-c – How to convert NSDictionary to NSData as a plist (without saving the dictionary)

iphonensdatansdictionaryobjective c

Does anyone know how to convert a NSDictionary object into an NSData object as a plist without saving the dictionary first?
I would like my iphone app to send an email with a plist containing my dictionary attached. I am currently using skpsmtpmessage, http://code.google.com/p/skpsmtpmessage/, to send email.

Thanks in advance

Best Answer

You can use NSPropertyListSerialization class for that. Have a look at its method:

+ (NSData *)dataFromPropertyList:(id)plist format:(NSPropertyListFormat)format
                              errorDescription:(NSString **)errorString

Returns an NSData object containing a given property list in a specified format.