This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Alamofireと組み合わせて利用する | |
*/ | |
// Modelファイル内のメソッド定義 | |
func getDataFromAPI() -> BFTask<AnyObject> { | |
let taskCompletion = BFTaskCompletionSource<AnyObject>() | |
let url = "..." | |
Alamofire.request(url, method: .get) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Alamofire | |
import PromiseKit | |
import SwiftyJSON | |
class APIManagerForPickupMessage { | |
private let baseUrl = "APIのエンドポイントとなるURLを指定する" | |
// MARK: - Singleton Instance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ArticleViewController: UIViewController { | |
// カテゴリーの一覧データ | |
private let categoryList: [String] = ArticleMock.getArticleCategories() | |
// 現在表示しているViewControllerのタグ番号 | |
private var currentCategoryIndex: Int = 0 | |
// ページングして表示させるViewControllerを保持する配列 | |
private var targetViewControllerLists: [UIViewController] = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// MEMO: こちらのデータはJSONから生成する | |
struct FeaturedModel: Decodable { | |
let id: Int | |
let title: String | |
let imageName: String | |
private enum Keys: String, CodingKey { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
・・・(省略)・・・ | |
func applicationDidEnterBackground(_ application: UIApplication) { | |
print("applicationDidEnterBackground: バックグラウンドへ移行完了した時") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// MEMO: Swift5.1から登場した「Property Wrappers」を利用したDependency Injectionの実装例 | |
// https://stackoverflow.com/questions/61316547/nested-dependency-injection-through-property-wrapper-crashes | |
// 補足: Property Wrappersについて | |
// https://dev.classmethod.jp/articles/property-wrappers/ | |
enum Dependencies { | |
// MARK: - Struct (for Name of Dependencies) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// (1) DependenciesDefinition.swift | |
// それぞれのクラスの依存関係を定義する | |
import Foundation | |
final class DependenciesDefinition { | |
// MARK: - Function | |
// MEMO: PropertyWrapperを利用したDependencyInjectionを実施する | |
func inject() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// (1) APIRequestManager.swift | |
// Infra層部分 | |
import Foundation | |
import RxSwift | |
// MARK: - Protocol | |
protocol APIRequestProtocol { | |
func getAnnoucements() -> Single<AnnouncementListResponse> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import PlaygroundSupport | |
protocol WaterfallLayoutDelegate: AnyObject { | |
func numberOfColumns() -> Int | |
func columnsSize(at indexPath: IndexPath) -> CGSize | |
func columnSpace() -> CGFloat | |
} | |
final class WaterfallLayoutViewController: UIViewController, UICollectionViewDataSource { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// UI実装であると嬉しいレシピブック掲載サンプル変更点(iOS14対応箇所) | |
// 1. UINavigationController左上にある戻るボタンをロングタップした際に一気に最初の画面に戻る機能への対応 | |
// 本書の中では、UINavigationControllerExtension.swiftに該当箇所があります。 | |
// 戻るボタンの「戻る」テキストを削除した状態にするメソッド | |
func removeBackButtonText() { | |
self.navigationController!.navigationBar.tintColor = UIColor(code: "#ffffff") | |
if #available(iOS 14.0, *) { | |
self.navigationItem.backButtonDisplayMode = .minimal |