Memo Project ๐๐ปโโ (2021.11.9 ~)
- ๊ธฐ๋ณธ์ ์ธ ๋ ์ด์์ ๋ฐ ์ฐ๊ฒฐ - 11.9
- ์ธํธ๋ก, Realm - 11.10
- ์ค๋ฅ๊ฐ ๋๋ฌด ๋ง์ / ์์น๋ฐ ์ปจํธ๋กค๋ฌ ๊ตฌํ ํด์ผํจ - 11.12
- ๋ ์งํฌ๋งท, ํค๋ณด๋, ๊ณต์ ๊ธฐ๋ฅ, ๋ฐฑ๋ฒํผ์ ๋ฉ๋ชจ์ ์ฅ, ๋๊ฐ์ ์นผ๋ผ์ผ๋ก ์ ์ฅ ๋ฏธ๋ฐ์ - 11.15
- ์ด๋ ดํ์ด ๋ค์๋ MVC ๋์์ธ ํจํด์ด ๊ธฐ์ต์ด๋ ํ ๋ฒ ์ ์ฉํด๋ณด๊ณ ์ ํด๋๊ด๋ฆฌ๋ฅผ ํด๋ณด์์ผ๋ ์ ํํ๊ฒ ํ๊ณ ์๋์ง ์์ง์ ๋ชจ๋ฅด๊ฒ ๋ค.
[ MVC ]
- Model : Realm table๊ณผ MemoviewController์์ ์ฌ์ฉํ๋ ํ๋กํ ์ฝ์ ์ ์ฅ
- View : Storyboard ๋ฐ cell
- Controller : Memo, Walkthrough,Editor / controller์ Extension
๊ฐ์ธํ๋ก์ ํธ์์ ํ์คํ๊ฒ ์ตํ๋๊ณ MVVM์ ๋ํด์ ํ์ตํด๋ณด์.
protocol SendDataDelegate {
//๊ธฐ๋ณธ
func textData(title : String,content : String)
//๊ณ ์ + ๋ฉ๋ชจ
func textDataTag(title : String,content : String,tagging : Int)
//์์น
func textDataId(title : String,content : String,id : ObjectId)
}
- ์๋นํ ์ ๋ฅผ ๋จน์ธ ๋ถ๋ถ์ด๋ค.
- ์๋ก์ด ๋ฉ๋ชจ๋ฅผ ์์ฑ์์๋ ๊ฐ์ฅ ์์์ textData๋ฅผ ์ด์ฉ
- ๊ณ ์ ๋์ด ์๊ฑฐ๋ ๋ฉ๋ชจ์ ์์ ๊ฒฝ์ฐ์๋ textDataTag๋ฅผ ์ด์ฉ
- ๊ฒ์์์๋ textDataId๋ฅผ ์ด์ฉํ๋๋ฐ ์ด ๊ฒฝ์ฐ์๋ ์น์
์ด ํ๋์ด๊ธฐ ๋๋ฌธ์ indexPath.section/row๋ฅผ ์ด์ฉํ๊ธฐ ๊น๋ค๋ก์ id๊ฐ์ ์ด์ฉํด ์ ๋ฌํ๋ค.
func numberFormatter(number: Int) -> String {
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
return numberFormatter.string(from: NSNumber(value: number))!
}
- Date๋ง๊ณ ์ซ์๋ Format์ ์ ํด์ค์ ์๊ฒ ๋ง๋ค์ด์ฃผ๋ ํจ์
let attributtedString = NSMutableAttributedString(string: cell.titleLabel.text!)
attributtedString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.red, range: (cell.titleLabel.text! as NSString).range(of:"\(searchController.searchBar.text!)"))
cell.titleLabel.attributedText = attributtedString
func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {}
- ๊น๋จน์ง ๋ง์๐
//์ฒ์์ธ์ง ์๋์ง ํ์ธ
func firstLogInCheck(){
//๋๋ฒ์ด์ ์คํ
if userDefaults.bool(forKey: "FirstLogIn") { return }
//์ฒ์ ์คํ
userDefaults.set(true,forKey: "FirstLogIn")
//์ฒ์์ด๋ฏ๋ก ํํ ๋ฆฌ์ผ ์๋ด
let storyboard = UIStoryboard(name: "walkthrough", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "walkthrough") as! WalkthroughViewController
//overFullScreen์ด์ฌ์ผ ๋ผ์ดํ์ฌ์ดํด ์๊ฒน์น๋ค!
vc.modalPresentationStyle = .overFullScreen
self.present(vc, animated: true, completion: nil)
}
- UserDefaults๋ฅผ ์ด์ฉํด ํค์ Bool ํํ๋ก ์ ์ฅํด๋๊ณ ์ ํ๋ฆฌ์ผ์ด์ ์ ํค๋ฉด ํ์ธํ๋ค.
- ๋ค๋ง Appdelegate๋ฅผ ํ์ฉํ๋ฉด ํ๋ฒ๋ง ํ์ธํ ์ ์๋ค๋ ๊ธ์ ๋ณธ ๊ฒ ๊ฐ์ ํ์ธํด๋ณผ ํ์๊ฐ ์๋ค.
//๊ณ ์ ๋ ๋ฉ๋ชจ์ ๋ฉ๋ชจ๋ก ๋ถ๋ฆฌํ๊ธฐ ์ํ ํ๋กํผํฐ
var classifications : [String] {
return Set(Works.value(forKeyPath: "classification") as! [String]).sorted()
}
- indexPath.section / indexPath.row๋ฅผ ์ด์ฉํด์ ๋ถ๋ฆฌ๋๊ฒ ๋ณด์ฌ์ฃผ๋ ๊ณผ์ ์์ฒด๋ ์ฌ์ ์ผ๋ indexPath.row๊ฐ ๊ฒน์น๊ฒ ๋์ด ๊ณ ์ ๋ ๋ฉ๋ชจ์ ๊ฐ ํน์ ๋ฉ๋ชจ์ ๊ฐ์ด ํผ๋๋์ด ํ์๋๊ฑฐ๋ ์ค๋ฅ๊ฐ ๋ฐ์ํ์๋ค.
- Realm์ classification์ด๋ผ๋ ๋ณ์๋ฅผ ์ถ๊ฐํ๊ณ String ํ์ ์ผ๋ก '๊ณ ์ ๋ ๋ฉ๋ชจ'์ '๋ฉ๋ชจ'๋ก ๋๋๊ณ ์์ ํ๋กํผํฐ๋ฅผ ํ์ฉํ์ฌ ํ ์ด๋ธ ๋ทฐ์ ๋ณด์ฌ์ฃผ์๋ค.
- ์๋นํ ์ค๋์๊ฐ ์ ๋จน์๋ค.. ์์ง๋ ๋ถ๋ค๋ถ๋คํ๋ค..