これはどのように迅速に変換されますか?最低限必要なのは、電子メールメッセージに追加されたアプリ名、アプリのバージョン、ロケールまたは国です。メッセージのボディと付け加え運を持っていないのに電子メールメッセージ本文にアプリとデバイスの情報を表示する - スウィフト
NSString *appName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"];
UIDevice *currentDevice = [UIDevice currentDevice];
NSString *model = [currentDevice model];
NSString *systemVersion = [currentDevice systemVersion];
NSArray *languageArray = [NSLocale preferredLanguages];
NSString *language = [languageArray objectAtIndex:0];
NSLocale *locale = [NSLocale currentLocale];
NSString *country = [locale localeIdentifier];
NSString *appVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
NSString *emailBody = [NSString stringWithFormat:@"\n\n\n\n\n\n\n\n\nApp Name: %@ \nModel: %@ \nSystem Version: %@ \nLanguage: %@ \nCountry: %@ \nApp Version: %@", appName, model, systemVersion, language, country, appVersion];
は、これまでのところ私は
let appName = Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as! String
を見つけました。
これはこれまで私が行ってきたことです。
@IBAction func sendMail(_ sender: AnyObject) {
let recipients = ["[email protected]"]
let title = "App feedback"
let appName = Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as! String
let message = ""
let mc: MFMailComposeViewController = MFMailComposeViewController()
mc.mailComposeDelegate = self
mc.setToRecipients(recipients)
mc.setSubject(title)
mc.setMessageBody(message, isHTML: false)
self.present(mc, animated: true, completion: nil)
あなたはコードを変換していません。あなたの 'message'は空の文字列です。すべてのコードを変換し、次に成功しない場合は質問を投稿してください。 – rckoenes
はい、私はそれを追加する方法はわかりませんがわかります。プラス私はコードを変換するための助けを求めています。 – Enquinn
あなたはObjective-Cを素早く1行に翻訳しておらず、 'stringWithFormat:'がメッセージを作成するのに使われている穴の部分がありません。あなたは疑問に思っています。私はこのコードを持っていますので、Swift版を作成してください。この種の質問はぶつかり、下降する。すべてのObj-cラインをSwiftに変換します。 – rckoenes