React.note vs useMemo2020. 7. 10.
React.memo
- Higher order component.
- prop change만을 체크함. 감싼 컴포넌트 안에
useState
,useContext
등이 있다면, 역시 해당 state 변경에 따라 rerender됨.
useMemo
- Hook.
- deps array에 포함된 deps가 변경되지 않으면 memoized value를 반환하는 함수.
flex2020. 7. 9.
flex
flex-grow
, flex-shrink
, + flex-basis
의 shorthand이다.
syntax
- One-value syntax:
the value must be one of:
- a
<number>
: In this case it is interpreted asflex: <number> 1 0;
the<flex-shrink>
value is assumed to be1
and the<flex-basis>
value is assumed to be0
. - one of the keywords:
none
,auto
, orinitial
.
- a
- Two-value syntax:
the first value must be a
<number>
and it is interpreted as<flex-grow>
. The second value must be one of:- a
<number>
: then it is interpreted as<flex-shrink>
. - a valid value for width: then it is interpreted as
<flex-basis>
.
- a
- Three-value syntax:
the values must be in the following order:
- a
<number>
for<flex-grow>
. - a
<number>
for<flex-shrink>
. - a valid value for width for
<flex-basis>
.
- a
String interpolation produces a debug description for an optional value; did you mean to make this explicit?2020. 7. 8.
default:
- fatalError("Unexpected Segue identifier; \(segue.identifier)")
+ fatalError("Unexpected Segue identifier; \(String(describing: segue.identifier))")
default:
- fatalError("Unexpected Segue identifier; \(segue.identifier)")
+ fatalError("Unexpected Segue identifier; \(String(describing: segue.identifier))")
Delegation Pattern2020. 7. 6.
https://en.wikipedia.org/wiki/Delegation_pattern
class Rectangle(val width: Int, val height: Int) {
fun area() = width * height
}
class Window(val bounds: Rectangle) {
// Delegation
fun area() = bounds.area()
}
class Rectangle(val width: Int, val height: Int) {
fun area() = width * height
}
class Window(val bounds: Rectangle) {
// Delegation
fun area() = bounds.area()
}
Links
sourceViewController -> source2020. 7. 6.
Implement Navigation을 진행하다가 아래 워닝을 만났다.
//MARK: Actions
@IBAction func unwindToMealList(sender: UIStoryboardSegue) {
- if let sourceViewContoller = sender.sourceViewController as? MealViewController, let meal = sourceViewContoller.meal {
+ if let sourceViewContoller = sender.source as? MealViewController, let meal = sourceViewContoller.meal {
// Add new meal.
let newIndexPath = IndexPath(row: meals.count, section: 0)
meals.append(meal)
tableView.insertRows(at: [newIndexPath], with: .automatic)
}
}
//MARK: Actions
@IBAction func unwindToMealList(sender: UIStoryboardSegue) {
- if let sourceViewContoller = sender.sourceViewController as? MealViewController, let meal = sourceViewContoller.meal {
+ if let sourceViewContoller = sender.source as? MealViewController, let meal = sourceViewContoller.meal {
// Add new meal.
let newIndexPath = IndexPath(row: meals.count, section: 0)
meals.append(meal)
tableView.insertRows(at: [newIndexPath], with: .automatic)
}
}
`Could not insert new outlet connection` error2020. 7. 5.
문제
FoodTracker를 신나게 만드는 중이었는데, save
버튼을 MealViewController
에 연결시키려던 순간!
위와 같은 메시지를 보여주면서 안되는 경우가 생겼다.
해결
cmd+shift+K
를 눌러 product를 clean 한다.cmd+R
로 build + run을 한다.- 한 번 해본다.
- 안되면 xcode를 재시작한다.
How to show code info in Xcode (like vscode)2020. 7. 3.
option + click
Create a chrome shorcut to a bookmarklet2020. 6. 30.
Header vs Heading2020. 6. 30.
Header: "The upper portion of a page (or other) layout."
Heading: "The title or topic of a document, article, chapter, or of a section thereof."
Xcode 터미널에서 실행하기2020. 6. 30.
$ xed .
$ xed .