回答編集履歴
5
修正
test
CHANGED
@@ -18,6 +18,118 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
+
override func viewDidLoad() {
|
22
|
+
|
23
|
+
super.viewDidLoad()
|
24
|
+
|
25
|
+
Common.sendMail(self)
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
switch result.rawValue {
|
36
|
+
|
37
|
+
case MFMailComposeResultCancelled.rawValue:
|
38
|
+
|
39
|
+
print("Email Send Cancelled")
|
40
|
+
|
41
|
+
break
|
42
|
+
|
43
|
+
case MFMailComposeResultSaved.rawValue:
|
44
|
+
|
45
|
+
print("Email Saved as a Draft")
|
46
|
+
|
47
|
+
break
|
48
|
+
|
49
|
+
case MFMailComposeResultSent.rawValue:
|
50
|
+
|
51
|
+
print("Email Sent Successfully")
|
52
|
+
|
53
|
+
break
|
54
|
+
|
55
|
+
case MFMailComposeResultFailed.rawValue:
|
56
|
+
|
57
|
+
print("Email Send Failed")
|
58
|
+
|
59
|
+
break
|
60
|
+
|
61
|
+
default:
|
62
|
+
|
63
|
+
break
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
dismissViewControllerAnimated(true, completion: nil)
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
// 呼ばれるクラス
|
76
|
+
|
77
|
+
class Common:NSObject, MFMailComposeViewControllerDelegate {
|
78
|
+
|
79
|
+
class func sendMail<T: UIViewController where T: MFMailComposeViewControllerDelegate>(vc: T) {
|
80
|
+
|
81
|
+
if MFMailComposeViewController.canSendMail()==false {
|
82
|
+
|
83
|
+
print("Email Send Failed")
|
84
|
+
|
85
|
+
return
|
86
|
+
|
87
|
+
}
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
let mailViewController = MFMailComposeViewController()
|
92
|
+
|
93
|
+
mailViewController.mailComposeDelegate = vc
|
94
|
+
|
95
|
+
mailViewController.setSubject("エラー出ませんように")
|
96
|
+
|
97
|
+
let toRecipients = ["noerror_nolife@gmail.com"]
|
98
|
+
|
99
|
+
mailViewController.setToRecipients(toRecipients)
|
100
|
+
|
101
|
+
mailViewController.setMessageBody("", isHTML: false)
|
102
|
+
|
103
|
+
vc.presentViewController(mailViewController, animated: true, completion: nil)
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
```
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
追加質問の回答
|
114
|
+
|
115
|
+
---
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
```swift
|
120
|
+
|
121
|
+
import UIKit
|
122
|
+
|
123
|
+
import MessageUI
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
//呼ぶクラス
|
128
|
+
|
129
|
+
class ViewController: UIViewController {
|
130
|
+
|
131
|
+
|
132
|
+
|
21
133
|
// インスタンスとして保持
|
22
134
|
|
23
135
|
var common: Common!
|
@@ -32,6 +144,52 @@
|
|
32
144
|
|
33
145
|
}
|
34
146
|
|
147
|
+
}
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
// 呼ばれるクラス
|
152
|
+
|
153
|
+
class Common:NSObject, MFMailComposeViewControllerDelegate {
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
var vc: UIViewController!
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
func sendMail(vc: UIViewController) -> Common? {
|
162
|
+
|
163
|
+
if MFMailComposeViewController.canSendMail()==false {
|
164
|
+
|
165
|
+
print("Email Send Failed")
|
166
|
+
|
167
|
+
return nil;
|
168
|
+
|
169
|
+
}
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
self.vc = vc
|
174
|
+
|
175
|
+
let mailViewController = MFMailComposeViewController()
|
176
|
+
|
177
|
+
mailViewController.mailComposeDelegate = self
|
178
|
+
|
179
|
+
mailViewController.setSubject("エラー出ませんように")
|
180
|
+
|
181
|
+
let toRecipients = ["noerror_nolife@gmail.com"]
|
182
|
+
|
183
|
+
mailViewController.setToRecipients(toRecipients)
|
184
|
+
|
185
|
+
mailViewController.setMessageBody("", isHTML: false)
|
186
|
+
|
187
|
+
vc.presentViewController(mailViewController, animated: true, completion: nil)
|
188
|
+
|
189
|
+
return self
|
190
|
+
|
191
|
+
}
|
192
|
+
|
35
193
|
|
36
194
|
|
37
195
|
func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {
|
@@ -70,184 +228,12 @@
|
|
70
228
|
|
71
229
|
}
|
72
230
|
|
73
|
-
dismissViewControllerAnimated(true, completion: nil)
|
231
|
+
vc.dismissViewControllerAnimated(true, completion: nil)
|
74
|
-
|
232
|
+
|
75
|
-
}
|
233
|
+
}
|
76
|
-
|
234
|
+
|
77
|
-
}
|
235
|
+
}
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
236
|
+
|
86
|
-
|
87
|
-
|
237
|
+
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
func sendMail<T: UIViewController where T: MFMailComposeViewControllerDelegate>(vc: T) -> Common? {
|
92
|
-
|
93
|
-
if MFMailComposeViewController.canSendMail()==false {
|
94
|
-
|
95
|
-
print("Email Send Failed")
|
96
|
-
|
97
|
-
return nil;
|
98
|
-
|
99
|
-
}
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
let mailViewController = MFMailComposeViewController()
|
104
|
-
|
105
|
-
mailViewController.mailComposeDelegate = vc
|
106
|
-
|
107
|
-
mailViewController.setSubject("エラー出ませんように")
|
108
|
-
|
109
|
-
let toRecipients = ["noerror_nolife@gmail.com"]
|
110
|
-
|
111
|
-
mailViewController.setToRecipients(toRecipients)
|
112
|
-
|
113
|
-
mailViewController.setMessageBody("", isHTML: false)
|
114
|
-
|
115
|
-
vc.presentViewController(mailViewController, animated: true, completion: nil)
|
116
|
-
|
117
|
-
return self
|
118
|
-
|
119
|
-
}
|
120
|
-
|
121
|
-
}
|
122
238
|
|
123
239
|
```
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
追加質問の回答
|
128
|
-
|
129
|
-
---
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
```swift
|
134
|
-
|
135
|
-
import UIKit
|
136
|
-
|
137
|
-
import MessageUI
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
//呼ぶクラス
|
142
|
-
|
143
|
-
class ViewController: UIViewController {
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
// インスタンスとして保持
|
148
|
-
|
149
|
-
var common: Common!
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
override func viewDidLoad() {
|
154
|
-
|
155
|
-
super.viewDidLoad()
|
156
|
-
|
157
|
-
common = Common().sendMail(self)
|
158
|
-
|
159
|
-
}
|
160
|
-
|
161
|
-
}
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
// 呼ばれるクラス
|
166
|
-
|
167
|
-
class Common:NSObject, MFMailComposeViewControllerDelegate {
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
var vc: UIViewController!
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
func sendMail(vc: UIViewController) -> Common? {
|
176
|
-
|
177
|
-
if MFMailComposeViewController.canSendMail()==false {
|
178
|
-
|
179
|
-
print("Email Send Failed")
|
180
|
-
|
181
|
-
return nil;
|
182
|
-
|
183
|
-
}
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
self.vc = vc
|
188
|
-
|
189
|
-
let mailViewController = MFMailComposeViewController()
|
190
|
-
|
191
|
-
mailViewController.mailComposeDelegate = self
|
192
|
-
|
193
|
-
mailViewController.setSubject("エラー出ませんように")
|
194
|
-
|
195
|
-
let toRecipients = ["noerror_nolife@gmail.com"]
|
196
|
-
|
197
|
-
mailViewController.setToRecipients(toRecipients)
|
198
|
-
|
199
|
-
mailViewController.setMessageBody("", isHTML: false)
|
200
|
-
|
201
|
-
vc.presentViewController(mailViewController, animated: true, completion: nil)
|
202
|
-
|
203
|
-
return self
|
204
|
-
|
205
|
-
}
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
switch result.rawValue {
|
214
|
-
|
215
|
-
case MFMailComposeResultCancelled.rawValue:
|
216
|
-
|
217
|
-
print("Email Send Cancelled")
|
218
|
-
|
219
|
-
break
|
220
|
-
|
221
|
-
case MFMailComposeResultSaved.rawValue:
|
222
|
-
|
223
|
-
print("Email Saved as a Draft")
|
224
|
-
|
225
|
-
break
|
226
|
-
|
227
|
-
case MFMailComposeResultSent.rawValue:
|
228
|
-
|
229
|
-
print("Email Sent Successfully")
|
230
|
-
|
231
|
-
break
|
232
|
-
|
233
|
-
case MFMailComposeResultFailed.rawValue:
|
234
|
-
|
235
|
-
print("Email Send Failed")
|
236
|
-
|
237
|
-
break
|
238
|
-
|
239
|
-
default:
|
240
|
-
|
241
|
-
break
|
242
|
-
|
243
|
-
}
|
244
|
-
|
245
|
-
vc.dismissViewControllerAnimated(true, completion: nil)
|
246
|
-
|
247
|
-
}
|
248
|
-
|
249
|
-
}
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
```
|
4
修正
test
CHANGED
@@ -18,15 +18,21 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
+
// インスタンスとして保持
|
22
|
+
|
23
|
+
var common: Common!
|
24
|
+
|
25
|
+
|
26
|
+
|
21
27
|
override func viewDidLoad() {
|
22
28
|
|
23
29
|
super.viewDidLoad()
|
24
30
|
|
25
|
-
Common.sendMail(self)
|
31
|
+
common = Common().sendMail(self)
|
26
|
-
|
32
|
+
|
27
|
-
}
|
33
|
+
}
|
28
|
-
|
29
|
-
|
34
|
+
|
35
|
+
|
30
36
|
|
31
37
|
func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {
|
32
38
|
|
@@ -72,17 +78,23 @@
|
|
72
78
|
|
73
79
|
|
74
80
|
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
75
|
-
// 呼ばれるクラス
|
85
|
+
// 呼ばれるクラス
|
76
|
-
|
77
|
-
|
86
|
+
|
78
|
-
|
79
|
-
|
87
|
+
class Common:NSObject, MFMailComposeViewControllerDelegate {
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
func sendMail<T: UIViewController where T: MFMailComposeViewControllerDelegate>(vc: T) -> Common? {
|
80
92
|
|
81
93
|
if MFMailComposeViewController.canSendMail()==false {
|
82
94
|
|
83
95
|
print("Email Send Failed")
|
84
96
|
|
85
|
-
return ;
|
97
|
+
return nil;
|
86
98
|
|
87
99
|
}
|
88
100
|
|
@@ -90,7 +102,7 @@
|
|
90
102
|
|
91
103
|
let mailViewController = MFMailComposeViewController()
|
92
104
|
|
93
|
-
mailViewController.mailComposeDelegate = vc
|
105
|
+
mailViewController.mailComposeDelegate = vc
|
94
106
|
|
95
107
|
mailViewController.setSubject("エラー出ませんように")
|
96
108
|
|
@@ -100,53 +112,11 @@
|
|
100
112
|
|
101
113
|
mailViewController.setMessageBody("", isHTML: false)
|
102
114
|
|
103
|
-
if let vc = vc as? UIViewController {
|
104
|
-
|
105
|
-
|
115
|
+
vc.presentViewController(mailViewController, animated: true, completion: nil)
|
116
|
+
|
106
|
-
|
117
|
+
return self
|
118
|
+
|
107
|
-
|
119
|
+
}
|
108
|
-
|
109
|
-
}
|
110
|
-
|
111
|
-
}
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
// 呼ばれるクラス(案2)
|
116
|
-
|
117
|
-
class Common:NSObject {
|
118
|
-
|
119
|
-
class func sendMail(vc: UIViewController) {
|
120
|
-
|
121
|
-
if MFMailComposeViewController.canSendMail()==false {
|
122
|
-
|
123
|
-
print("Email Send Failed")
|
124
|
-
|
125
|
-
return ;
|
126
|
-
|
127
|
-
}
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
if vc is MFMailComposeViewControllerDelegate {
|
132
|
-
|
133
|
-
let mailViewController = MFMailComposeViewController()
|
134
|
-
|
135
|
-
mailViewController.mailComposeDelegate = vc as? MFMailComposeViewControllerDelegate
|
136
|
-
|
137
|
-
mailViewController.setSubject("エラー出ませんように")
|
138
|
-
|
139
|
-
let toRecipients = ["noerror_nolife@gmail.com"]
|
140
|
-
|
141
|
-
mailViewController.setToRecipients(toRecipients)
|
142
|
-
|
143
|
-
mailViewController.setMessageBody("", isHTML: false)
|
144
|
-
|
145
|
-
vc.presentViewController(mailViewController, animated: true, completion: nil)
|
146
|
-
|
147
|
-
}
|
148
|
-
|
149
|
-
}
|
150
120
|
|
151
121
|
}
|
152
122
|
|
3
修正
test
CHANGED
@@ -151,3 +151,133 @@
|
|
151
151
|
}
|
152
152
|
|
153
153
|
```
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
追加質問の回答
|
158
|
+
|
159
|
+
---
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
```swift
|
164
|
+
|
165
|
+
import UIKit
|
166
|
+
|
167
|
+
import MessageUI
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
//呼ぶクラス
|
172
|
+
|
173
|
+
class ViewController: UIViewController {
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
// インスタンスとして保持
|
178
|
+
|
179
|
+
var common: Common!
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
override func viewDidLoad() {
|
184
|
+
|
185
|
+
super.viewDidLoad()
|
186
|
+
|
187
|
+
common = Common().sendMail(self)
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
}
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
// 呼ばれるクラス
|
196
|
+
|
197
|
+
class Common:NSObject, MFMailComposeViewControllerDelegate {
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
var vc: UIViewController!
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
func sendMail(vc: UIViewController) -> Common? {
|
206
|
+
|
207
|
+
if MFMailComposeViewController.canSendMail()==false {
|
208
|
+
|
209
|
+
print("Email Send Failed")
|
210
|
+
|
211
|
+
return nil;
|
212
|
+
|
213
|
+
}
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
self.vc = vc
|
218
|
+
|
219
|
+
let mailViewController = MFMailComposeViewController()
|
220
|
+
|
221
|
+
mailViewController.mailComposeDelegate = self
|
222
|
+
|
223
|
+
mailViewController.setSubject("エラー出ませんように")
|
224
|
+
|
225
|
+
let toRecipients = ["noerror_nolife@gmail.com"]
|
226
|
+
|
227
|
+
mailViewController.setToRecipients(toRecipients)
|
228
|
+
|
229
|
+
mailViewController.setMessageBody("", isHTML: false)
|
230
|
+
|
231
|
+
vc.presentViewController(mailViewController, animated: true, completion: nil)
|
232
|
+
|
233
|
+
return self
|
234
|
+
|
235
|
+
}
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
switch result.rawValue {
|
244
|
+
|
245
|
+
case MFMailComposeResultCancelled.rawValue:
|
246
|
+
|
247
|
+
print("Email Send Cancelled")
|
248
|
+
|
249
|
+
break
|
250
|
+
|
251
|
+
case MFMailComposeResultSaved.rawValue:
|
252
|
+
|
253
|
+
print("Email Saved as a Draft")
|
254
|
+
|
255
|
+
break
|
256
|
+
|
257
|
+
case MFMailComposeResultSent.rawValue:
|
258
|
+
|
259
|
+
print("Email Sent Successfully")
|
260
|
+
|
261
|
+
break
|
262
|
+
|
263
|
+
case MFMailComposeResultFailed.rawValue:
|
264
|
+
|
265
|
+
print("Email Send Failed")
|
266
|
+
|
267
|
+
break
|
268
|
+
|
269
|
+
default:
|
270
|
+
|
271
|
+
break
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
vc.dismissViewControllerAnimated(true, completion: nil)
|
276
|
+
|
277
|
+
}
|
278
|
+
|
279
|
+
}
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
```
|
2
修正
test
CHANGED
@@ -72,7 +72,7 @@
|
|
72
72
|
|
73
73
|
|
74
74
|
|
75
|
-
//呼ばれるクラス
|
75
|
+
// 呼ばれるクラス(案1)
|
76
76
|
|
77
77
|
class Common:NSObject {
|
78
78
|
|
@@ -110,4 +110,44 @@
|
|
110
110
|
|
111
111
|
}
|
112
112
|
|
113
|
+
|
114
|
+
|
115
|
+
// 呼ばれるクラス(案2)
|
116
|
+
|
117
|
+
class Common:NSObject {
|
118
|
+
|
119
|
+
class func sendMail(vc: UIViewController) {
|
120
|
+
|
121
|
+
if MFMailComposeViewController.canSendMail()==false {
|
122
|
+
|
123
|
+
print("Email Send Failed")
|
124
|
+
|
125
|
+
return ;
|
126
|
+
|
127
|
+
}
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
if vc is MFMailComposeViewControllerDelegate {
|
132
|
+
|
133
|
+
let mailViewController = MFMailComposeViewController()
|
134
|
+
|
135
|
+
mailViewController.mailComposeDelegate = vc as? MFMailComposeViewControllerDelegate
|
136
|
+
|
137
|
+
mailViewController.setSubject("エラー出ませんように")
|
138
|
+
|
139
|
+
let toRecipients = ["noerror_nolife@gmail.com"]
|
140
|
+
|
141
|
+
mailViewController.setToRecipients(toRecipients)
|
142
|
+
|
143
|
+
mailViewController.setMessageBody("", isHTML: false)
|
144
|
+
|
145
|
+
vc.presentViewController(mailViewController, animated: true, completion: nil)
|
146
|
+
|
147
|
+
}
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
}
|
152
|
+
|
113
153
|
```
|
1
修正
test
CHANGED
@@ -76,7 +76,7 @@
|
|
76
76
|
|
77
77
|
class Common:NSObject {
|
78
78
|
|
79
|
-
class func sendMail
|
79
|
+
class func sendMail<T: MFMailComposeViewControllerDelegate>(vc: T) {
|
80
80
|
|
81
81
|
if MFMailComposeViewController.canSendMail()==false {
|
82
82
|
|
@@ -88,19 +88,19 @@
|
|
88
88
|
|
89
89
|
|
90
90
|
|
91
|
-
i
|
91
|
+
let mailViewController = MFMailComposeViewController()
|
92
92
|
|
93
|
-
|
93
|
+
mailViewController.mailComposeDelegate = vc
|
94
94
|
|
95
|
-
|
95
|
+
mailViewController.setSubject("エラー出ませんように")
|
96
96
|
|
97
|
-
|
97
|
+
let toRecipients = ["noerror_nolife@gmail.com"]
|
98
98
|
|
99
|
-
|
99
|
+
mailViewController.setToRecipients(toRecipients)
|
100
100
|
|
101
|
-
|
101
|
+
mailViewController.setMessageBody("", isHTML: false)
|
102
102
|
|
103
|
-
|
103
|
+
if let vc = vc as? UIViewController {
|
104
104
|
|
105
105
|
vc.presentViewController(mailViewController, animated: true, completion: nil)
|
106
106
|
|