Skip to content

Commit

Permalink
feat: mainTableView DataSource 지정 (#8)
Browse files Browse the repository at this point in the history
테이블 뷰와 DataSource 연결
  • Loading branch information
Settpark committed Apr 19, 2021
1 parent 1ee08f0 commit 1fd22f1
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 24 deletions.
4 changes: 4 additions & 0 deletions ios/sidedish/sidedish.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
8214B70B262DE07A004467C2 /* MenuCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8214B70A262DE07A004467C2 /* MenuCell.swift */; };
8214B70E262DE253004467C2 /* MainTableViewDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8214B70D262DE253004467C2 /* MainTableViewDataSource.swift */; };
82FDB9C7262DCFD8009E3EB7 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82FDB9C6262DCFD8009E3EB7 /* AppDelegate.swift */; };
82FDB9C9262DCFD8009E3EB7 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82FDB9C8262DCFD8009E3EB7 /* SceneDelegate.swift */; };
82FDB9CB262DCFD8009E3EB7 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82FDB9CA262DCFD8009E3EB7 /* ViewController.swift */; };
Expand All @@ -18,6 +19,7 @@

/* Begin PBXFileReference section */
8214B70A262DE07A004467C2 /* MenuCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MenuCell.swift; sourceTree = "<group>"; };
8214B70D262DE253004467C2 /* MainTableViewDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainTableViewDataSource.swift; sourceTree = "<group>"; };
82FDB9C3262DCFD8009E3EB7 /* sidedish.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = sidedish.app; sourceTree = BUILT_PRODUCTS_DIR; };
82FDB9C6262DCFD8009E3EB7 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
82FDB9C8262DCFD8009E3EB7 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -61,6 +63,7 @@
82FDB9C6262DCFD8009E3EB7 /* AppDelegate.swift */,
82FDB9C8262DCFD8009E3EB7 /* SceneDelegate.swift */,
82FDB9CA262DCFD8009E3EB7 /* ViewController.swift */,
8214B70D262DE253004467C2 /* MainTableViewDataSource.swift */,
8214B70A262DE07A004467C2 /* MenuCell.swift */,
82FDB9CC262DCFD8009E3EB7 /* Main.storyboard */,
82FDB9CF262DCFD8009E3EB7 /* Assets.xcassets */,
Expand Down Expand Up @@ -143,6 +146,7 @@
82FDB9CB262DCFD8009E3EB7 /* ViewController.swift in Sources */,
82FDB9C7262DCFD8009E3EB7 /* AppDelegate.swift in Sources */,
8214B70B262DE07A004467C2 /* MenuCell.swift in Sources */,
8214B70E262DE253004467C2 /* MainTableViewDataSource.swift in Sources */,
82FDB9C9262DCFD8009E3EB7 /* SceneDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
6 changes: 0 additions & 6 deletions ios/sidedish/sidedish/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate {


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

// MARK: UISceneSession Lifecycle

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}

func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}


Expand Down
2 changes: 1 addition & 1 deletion ios/sidedish/sidedish/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
</view>
<navigationItem key="navigationItem" id="Cyp-V7-tSn"/>
<connections>
<outlet property="menuTableView" destination="xCR-Zq-P0F" id="0Jf-hX-JgH"/>
<outlet property="menuTableView" destination="xCR-Zq-P0F" id="hd5-Me-D53"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="cbY-9O-M9K" sceneMemberID="firstResponder"/>
Expand Down
19 changes: 19 additions & 0 deletions ios/sidedish/sidedish/MainTableViewDataSource.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// MainTableViewDataSource.swift
// sidedish
//
// Created by 박정하 on 2021/04/19.
//

import UIKit

class MainTableViewDataSource : NSObject, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell : MenuCell = tableView.dequeueReusableCell(withIdentifier: "MenuCell", for: indexPath) as? MenuCell else { return UITableViewCell() }
return cell
}
}
16 changes: 0 additions & 16 deletions ios/sidedish/sidedish/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,22 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {


func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let _ = (scene as? UIWindowScene) else { return }
}

func sceneDidDisconnect(_ scene: UIScene) {
// Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded.
// Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
}

func sceneDidBecomeActive(_ scene: UIScene) {
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}

func sceneWillResignActive(_ scene: UIScene) {
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
}

func sceneWillEnterForeground(_ scene: UIScene) {
// Called as the scene transitions from the background to the foreground.
// Use this method to undo the changes made on entering the background.
}

func sceneDidEnterBackground(_ scene: UIScene) {
// Called as the scene transitions from the foreground to the background.
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.
}


Expand Down
20 changes: 19 additions & 1 deletion ios/sidedish/sidedish/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,26 @@

import UIKit

class ViewController: UIViewController {
class MainViewController: UIViewController {
@IBOutlet weak var menuTableView: UITableView!

private let tableViewDataSource : MainTableViewDataSource?

override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
self.tableViewDataSource = nil
super.init(nibName: nil, bundle: nil)
}

required init?(coder: NSCoder) {
self.tableViewDataSource = MainTableViewDataSource()
super.init(coder: coder)
}

override func loadView() {
super.loadView()
self.menuTableView.dataSource = tableViewDataSource
}

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
Expand Down

0 comments on commit 1fd22f1

Please sign in to comment.