- 123
- 456
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
__attribute__((objc_subclassing_restricted)) | |
__attribute__((swift_name("PokeApi"))) | |
@interface AppPokeApi : KotlinBase | |
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); | |
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); | |
- (void)getPokemonListSuccess:(AppKotlinUnit *(^)(NSArray<AppPokemonEntry *> *))success failure:(AppKotlinUnit *(^)(AppKotlinThrowable * _Nullable))failure __attribute__((swift_name("getPokemonList(success:failure:)"))); | |
@end; |
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 app | |
class PokeListViewController: UIViewController { | |
@IBOutlet var pokemonSprite: UIImageView! | |
@IBOutlet var pokemonInfo: UILabel! | |
@IBOutlet var pokeListTableView: UITableView! | |
internal var pokeList: [PokemonEntry] = [] | |
internal var api = PokeApi() |
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
package com.raywenderlich.pokelist | |
import com.raywenderlich.pokelist.shared.ApplicationDispatcher | |
import com.raywenderlich.pokelist.shared.Image | |
import io.ktor.client.HttpClient | |
import io.ktor.client.request.get | |
import kotlinx.coroutines.GlobalScope | |
import kotlinx.coroutines.launch | |
import kotlinx.serialization.json.Json |
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
package com.raywenderlich.pokelist | |
import kotlinx.serialization.Serializable | |
@Serializable | |
data class Pokemon( | |
val name: String, | |
val url: String | |
) | |
@Serializable |
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
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? // UIApplicationDelegate expects an optional UIWindow | |
private var appCoordinator: AppCoordinator! | |
func application(_ application: UIApplication, | |
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { | |
window = UIWindow(frame: UIScreen.main.bounds) |
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 | |
/// A UITextView subclass with placeholder text support. | |
/// It uses another UILabel to show the placeholder, shown when text is empty. | |
class PlaceholderTextView: UITextView { | |
lazy var placeholderLabel: UILabel = { | |
let label = UILabel() | |
label.textColor = UIColor(white: 0.5, alpha: 0.85) | |
label.backgroundColor = .clear |
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 RxSwift // Version 3.2.0 | |
import RxCocoa // Version 3.2.0 | |
typealias KeyboardHeightInfo = (CGFloat, TimeInterval) | |
func keyboardHeight() -> Driver<KeyboardHeightInfo> { | |
return Observable | |
.from([ | |
NotificationCenter.default.rx.notification(NSNotification.Name.UIKeyboardWillShow) | |
.map { notification -> KeyboardHeightInfo in |
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
// | |
// MapValueExample.swift | |
// ViKi | |
// | |
// Created by Thongchai Kolyutsakul on 29/5/17. | |
// | |
// | |
import Foundation | |
import SwiftyJSON |
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
typealias NumType = Double | |
var calculatedFibs = [NumType: NumType]() | |
func fib(num: NumType) -> NumType { | |
guard num > 1 else { // when num is 0, 1, just return 0, 1. | |
return num | |
} | |
if let cached = calculatedFibs[num] { // read cache | |
return cached |