macOS:Catalina 10.15.6
Xcode:12.0
Swift:5.3
I'm just an engineer studying swift
as a hobby. I don't use it at all at work.
I studied swift
once around 2015, and recently rekindled and re-studied.
If the value of spacing
contains a value other than 0, it seems that the constraint will be affected, so
It is better to enter 0 for spacing
(anywhere that does not affect the constraint).
Cannot declare conformance to 'NSObjectProtocol' in Swift;
I get angry.
In this case, ʻimport Foundation and then inheriting
NSObject is the solution. In my case, it was difficult because I deleted ʻimport Foundation
and tried and errored.
Multiple commands produce XXX
occurs.
If you look closely, Target [app name] has copy command from XXX
and Target [app name] has link command with output XXX
occur.
After a little research, something seemed to be in conflict. I think it was bad to manually copy the .swift
file on XCode
.
I wasn't sure, so I solved it by recreating the project.
The problem was solved by copying XXX.swift
and Main.storyboard
from the old project folder to the new project folder on Finder
.
I didn't know the location of Main.storyboard
for a moment, but on Finder
, it is in ... / [app name] / [app name] /Base.Iproj/
.
The site of here will be helpful.
I want to insert a line feed code and start a new line at any place, but it does not.
It didn't seem to work with \ n
, so I had to type \ n
.
You can enter \
by holding down the ʻoption key and pressing
\ `.
.swift
file ʻOutlet, ʻAction
I created a new ViewController
such as the transition destination and tried to connect with the same as the ViewController
from the beginning, but only the ʻObject item can select ʻExit
.
Select the target ViewController
on the Storyboard
.
Select the class corresponding to ViewController
from Custom Class
of ʻIdentity Inspector`.
(Image modified)
TableView
In order to prevent the bloat of ViewController
, you can create a separate class that inherits ʻUITableViewDelegate and ʻUITableViewDataSource
and delegate the processing to that class.
In this case, there are some points to be aware of.
The instance of the class to be delegated must be created outside viewDidLoad ()
.
Well, if you think about it for a moment, it's natural.
If the delegation destination is ViewController
(yourself), it works fine even if you create an instance inviewDidLoad ()
.
Although it deviates from the main subject, if you want to instantiate in viewDidLoad ()
due to timing problems (if you want to do it after some processing), just declare variables outside viewDidLoad ()
and There is no problem if you substitute it in viewDidLoad ()
.
Recommended Posts