iOS μ±μμ RxSchoolMealλ₯Ό μ¬μ©νλ €λ©΄ RxSchoolMeal νμΌμ μλμ κ°μ΄ μν¬νΈ(import)ν΄μΌ ν©λλ€. λν νκ΅μ΄λ¦μ μ΄μ©ν΄ RxSchoolMealλ₯Ό μ΄κΈ°ν νλ κ³Όμ μ΄ νμν©λλ€. λ€μ μμ λ₯Ό μ°Έκ³ νμ¬ AppDelegate.swiftμ RxSchoolMealλ₯Ό μ΄κΈ°ννλ μ½λλ₯Ό μΆκ°ν©λλ€.
import RxSchoolMeal
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
γ
€...
SchoolCommon.initSchool(schoolName: <#νκ΅μ΄λ¦#>)
γ
€...
γ
€
}
κΈμ μ 보λ₯Ό κ°μ Έμ€λ μ½λμ κΈ°λ³Έμ μΈ ννμ λλ€.
MEAL.getMeal(<#λ μ§#>, timePart: <#μμ¬κ΅¬λΆ#>).subscribe(onSuccess: { meal in
print(meal)
})
.disposed(by: disposeBag)
<#λ μ§#>
λΌκ³ μμ± λμ΄μλ λΆλΆμλ MealDate
λΌλ μ΄λ¦μΌλ‘ μ μλ enumμ μ
λ ₯ν©λλ€.
Raw Value | Description |
---|---|
.today |
μ€λμ λνλ λλ€. |
.anotherDate(date: Date) |
μνλ λ μ§λ₯Ό Date νμ μΌλ‘ λ°μ΅λλ€. |
.plusMinusDay(day: Int) |
μ€λμ κΈ°μ€μΌλ‘ μ‘°ννκ³ μΆμ λ μ§κ° λͺμΌ νμΈμ§, λͺμΌ μ μΈμ§λ₯Ό IntνμμΌλ‘ λ°μ΅λλ€. |
getMeal()
ν¨μλ timePart: <#μμ¬κ΅¬λΆ#>
λΆλΆμ μμ±νμ§ μμλ λλλ‘ μ€λ²λ‘λ© λμ΄μμ΅λλ€.
λ§μ½ MealModel
λΌλ μ΄λ¦μΌλ‘ μ μλ structλ‘ μμΉ¨, μ μ¬, μ λ
λ©λ΄λ₯Ό λͺ¨λ λ°κ³ μΆλ€λ©΄ μμ±νμ§ μμΌμλ©΄ λ©λλ€.
νμ§λ§ μμΉ¨, μ μ¬, μ λ
μ€ νλλ₯Ό [String]
ννλ‘ λ°μλ³΄κ³ μΆλ€λ©΄ μμ±νμλ©΄ λ©λλ€.<#μμ¬κ΅¬λΆ#>
λΌκ³ μμ± λμ΄μλ λΆλΆμλ MealPartTime
μ΄λΌλ μ΄λ¦μΌλ‘ μ μλ enumμ μ
λ ₯ν©λλ€.
Raw Value | Description |
---|---|
.breakfast |
μμΉ¨λ°₯ μ λλ€. |
.lunch |
μ μ¬λ°₯ μ λλ€. |
.dinner |
μ λ λ°₯ μ λλ€. |
μλ μΈ μμ λ λͺ¨λ μ€λμ κΈμμ μ‘°νν©λλ€.
MEAL.getMeal(.today).subscribe(onSuccess: { meal in
print(meal)
}, onFailure: { err in
print(err)
})
.disposed(by: disposeBag)
MEAL.getMeal(.anotherDate(date: Date())).subscribe(onSuccess: { meal in
print(meal)
}, onFailure: { err in
print(err)
})
.disposed(by: disposeBag)
MEAL.getMeal(.plusMinusDay(day: 0)).subscribe(onSuccess: { meal in
print(meal)
}, onFailure: { err in
print(err)
})
.disposed(by: disposeBag)
μλ μμ λ μ΄μ μ κΈμμ€ μ μ¬λ§ κ°μ Έμ€λ μμ μ λλ€.
MEAL.getMeal(.plusMinusDay(day: -1), timePart: .lunch).subscribe(onSuccess: { meal in
print(meal)
}, onFailure: { err in
print(err)
})
.disposed(by: disposeBag)
# Podfile
use_frameworks!
target 'YOUR_TARGET_NAME' do
pod 'RxSchoolMeal', '1.0.3'
end
Replace YOUR_TARGET_NAME
and then, in the Podfile
directory, type:
$ pod install
Add this to Cartfile
github "kimxwan0319/RxSchoolMeal" "1.0.3"
$ carthage update
// Package.swift
dependencies: [
.package(url: "https://github.com/kimxwan0319/RxSchoolMeal", from: "1.0.3")
]
semicolondsmkr, [email protected]
RxSchoolMeal is available under the MIT license. See the LICENSE file for more info.
link |
Stars: 3 |
Last commit: 2 years ago |
#32
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics