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
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: こちらのデータは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
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 | |
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
/** | |
* 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
// その1: APIサーバーとの通信処理(JSONレスポンス取得) | |
/** | |
* APIへの通信処理: | |
* method: .get または .post | |
* parameters: [String : Any] 例. ["key" : value] | |
* encoding: JSONEncoding.default (パラメーターがない場合は不要) | |
* headers: [String : Any] 例. ["key" : value] (認可等が必要なユーザーのデータへアクセスしたい場合は必要) | |
*/ |
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 React, { Component } from 'react'; | |
// React-Reduxのインポート宣言 → ProviderタグでラップすることでReactコンポーネント内でStoreにアクセスできるようにする | |
import { Provider } from 'react-redux'; | |
// createStore, applyMiddlewareのインポート宣言 | |
import { createStore, applyMiddleware } from 'redux'; | |
// redux-thunkのインポート宣言 | |
import ReduxThunk from 'redux-thunk'; |
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 APIManagerForNewYorkTimes { | |
private let baseUrl = "https://api.nytimes.com/svc/search/v2/articlesearch.json" | |
private let key = Constants.NEWYORKTIMES_API_KEY | |
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
// 楽天レシピ別カテゴリランキングのAPIキー ※各自取得をお願いします。 | |
static let API_KEY_RAKUTEN_RECIPE_RANKING = "" |