Reputation: 6253
I have this NSDictionary in Objective c class and when I try convert to Swift, I get errors uncaught exception in appendString nil argument
NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/plain; charset=UTF-8",kSKPSMTPPartContentTypeKey,data,kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];
testMsg.parts = [NSArray arrayWithObjects:plainPart,nil];
Try to Sift:
var plainPart: NSDictionary = ["text/plain; charset=UTF-8":kSKPSMTPPartContentTypeKey, self.data: kSKPSMTPPartMessageKey, "8bit": kSKPSMTPPartContentTransferEncodingKey]
msg.parts = [plainPart]
What is incorrect in the code conversion?
Thanks!
Upvotes: 2
Views: 2165
Reputation: 64634
It looks like you may have the keys and values backwards. Try this:
var plainPart: NSDictionary = [kSKPSMTPPartContentTypeKey: "text/plain; charset=UTF-8", kSKPSMTPPartMessageKey: self.data , kSKPSMTPPartContentTransferEncodingKey : "8bit"]
Upvotes: 1
Reputation: 2702
Try this one:
var plainPart: NSDictionary = ["text/plain; charset=UTF-8":kSKPSMTPPartContentTypeKey, self.data: kSKPSMTPPartMessageKey, "8bit": kSKPSMTPPartContentTransferEncodingKey,nil]
I also head an exception, after adding nil as last argument the exception was gone.
Upvotes: 0