投稿

【SwiftUI】Cannot invoke initializer for type 'XXX' with an argument list of type エラーへの対処法

この記事の概要 SwiftUIにおける、Cannot invoke initializer for type 'FugaFuga' with an argument list of type '(hogehoge: hogehoge)'エラーにどう対処すればいいか、について書いていきます。 目次 この記事の概要 目次 やろうとしたこと 発生したエラー エラーの翻訳 解決策 参考文献 やろうとしたこと SwiftUIを勉強しており、Listを使ったデータ表示の方法を勉強していた。参考にしていたサイトは次のサイトである:SwiftUIでListを表示する https://swiswiswift.com/2019-11-13/ ここに書いてあるコードを参考に、以下のコードを自分で打った。 import SwiftUI //charcterクラス struct character : Identifiable { //characterクラスの中に付与したい情報の定義     var id : Int     let name : String } //Viewクラス struct ListSampleView : View {     //データベース(配列)の用意     let charas : [ Character ] = [         Character (id: 1 , name: "日向翔陽" ), //このコードに Cannot invoke initializer for type 'Character' with an argument list of type '(id: Int, name: String)'エラーが発生する。         Character (id: 2 , name: "影山飛雄" ),         Character (id: 3 , name: "月島 蛍" ),   ...

【SwiftUI】コピペで使える!SwiftUIでボタンを実装しよう

イメージ
この記事の概要 この記事では、SwiftUIでボタンの実装をする方法と、SwiftUIでボタンの色を変更したり、角を丸くする方法などをまとめました。また、余白を設定する方法なども以下に併記しています。 SwiftUIの初心者の方でも簡単にコピペで実装できるように、コードサンプルを設けているので、ぜひご自由に使ってみてください。 数字などのプロパティを自分オリジナルのものに変更することで、無限にカスタマイズをすることもできます。 目次 この記事の概要 目次 ボタンを作るには 今回実装するボタン コード ボタンを作るには [図1]XCode上部のメニュー XCode上部のメニューから[+]ボタンを押して、ボタンを追加します。 [図1-2] Buttonを選択 今回実装するボタン 今回はこの4つのボタンを実装します。 早速ですが、使うコードはこの4つ。                                   //ボタンその1                     Button (action: {} ) {                         Text ( "ボタンその1" )                     }                     //ボタンその2                     Button (action: {} ) { ...

【Git】How to fix: fatal: Exiting because of an unresolved conflict on GitHub

Abstract I tried to push my repository to Git, but because of the error:  fatal: Exiting because of an unresolved conflict,  it failed. So, I wrote down the solution how to fix this error on this article. I'm not English native speaker, so I'm sorry if English grammar is weird. ;) Index Abstract Index Environment What I tried Solution Conclusion Environment ・mac OS Catarina 10.15.1(2017) ・Rails 6 ・heroku What I tried I tried to pull git local repository to master branch on GitHub. master-branch $ git pull origin master  But the error below happens:     error: Pulling is not possible because you have unmerged files.     hint: Fix them up in the work tree, and then use 'git add/rm <file>'     hint: as appropriate to mark resolution and make a commit. fatal: Exiting because of an unresolved conflict.   I'm not used to use git, so I tried merge or revert git branch. But it doesn't work well. By the ...

【SwiftUI】 タイトルTextの下にサブタイトルTextをつける / Textの間に余白を入れる

イメージ
この記事の概要 SwiftUIで、.subheadLineプロパティを使って、サブタイトルを設定すると同時に、VStackや Hstackの使い方もマスターします。 目次 この記事の概要 目次 前回からの変更点 タイトルTextにサブタイトルを導入しよう サブタイトルにHStackViewを導入してViewを分割しよう 余白を入れよう まとめ 前回からの変更点 よくよく考えたら、ハイキュー!!のロゴってオレンジじゃん......... ということで修正              Text ( "ハイキュー!!" )                  . font (. title )                  . fontWeight (. heavy )                  . foregroundColor ( Color . pink ) から、              Text ( "ハイキュー!!" )                  . font (. title )                  . fontWeight (. heavy )                  . foregroundColor ( Color . orange ) に修正。 タイトルTextにサブタイトルを導入しよう まず、ライブプレビュー画面になっている方は、スマホの横に青い円ボタン...