teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

再変更 コードを```で囲みました

2018/08/22 11:31

投稿

hato810
hato810

スコア9

title CHANGED
File without changes
body CHANGED
@@ -2,22 +2,21 @@
2
2
  課題でカレンダーを作ることになり、Web記事のコードを参考に試してみたのですが、おそらくバージョンの違い所以で、下記の箇所でエラーが出ます。
3
3
 
4
4
  // インスタンス作成時にエラーが出たので修正
5
- '''
5
+ ```
6
6
    let calendar = NSCalendar.currentCalendar()
7
7
  // Fix => Cannot call value of non-function type 'Calendar'. replace with()
8
8
  // ! => 'currentCalendar' has benn renamed to 'current'
9
9
  let calendar = NSCalendar.current //自動修正結果
10
- '''
10
+ ```
11
11
 
12
12
  このインスタンスからメソッドを呼び出した箇所でエラーになっており、修正方法がわかりません。
13
-
14
- '''
13
+ ```
15
14
  // Fix => 'NSCalendarOptions' has benn renamed to 'NSCalendar.Options'
16
15
  return calendar.dateByAddingComponents(dateComponents, toDate: self, options: NSCalendarOptions(rawValue: 0))!
17
16
  // ! => Value of type 'Calendar' has no member 'dateByAddingComponents'
18
17
  return calendar.dateByAddingComponents(dateComponents, toDate: self, options: NSCalendar.Options(rawValue: 0))!
19
18
  }
20
- '''
19
+ ```
21
20
 
22
21
  解決方法ご存知の方、よろしくお願い致します。
23
22
 

1

コードを'''で囲みました

2018/08/22 11:31

投稿

hato810
hato810

スコア9

title CHANGED
File without changes
body CHANGED
@@ -2,19 +2,23 @@
2
2
  課題でカレンダーを作ることになり、Web記事のコードを参考に試してみたのですが、おそらくバージョンの違い所以で、下記の箇所でエラーが出ます。
3
3
 
4
4
  // インスタンス作成時にエラーが出たので修正
5
+ '''
5
6
    let calendar = NSCalendar.currentCalendar()
6
7
  // Fix => Cannot call value of non-function type 'Calendar'. replace with()
7
8
  // ! => 'currentCalendar' has benn renamed to 'current'
8
9
  let calendar = NSCalendar.current //自動修正結果
10
+ '''
9
11
 
10
12
  このインスタンスからメソッドを呼び出した箇所でエラーになっており、修正方法がわかりません。
11
13
 
14
+ '''
12
15
  // Fix => 'NSCalendarOptions' has benn renamed to 'NSCalendar.Options'
13
16
  return calendar.dateByAddingComponents(dateComponents, toDate: self, options: NSCalendarOptions(rawValue: 0))!
14
17
  // ! => Value of type 'Calendar' has no member 'dateByAddingComponents'
15
18
  return calendar.dateByAddingComponents(dateComponents, toDate: self, options: NSCalendar.Options(rawValue: 0))!
16
- }
19
+ }
17
-
20
+ '''
21
+
18
22
  解決方法ご存知の方、よろしくお願い致します。
19
23
 
20
24
  環境:Swift3.3