Skip to content

Instantly share code, notes, and snippets.

View tilltue's full-sized avatar
🙊
I may be slow to respond.

junhyi park tilltue

🙊
I may be slow to respond.
View GitHub Profile
public enum UploadStatus<Value> {
case progress(Progress)
case completion(Value)
case error(Error)
}
public protocol DataListner: AnyObject {
func remove()
}
킹피셔 crash issue 및 pull request
크래시 이슈
https://github.com/onevcat/Kingfisher/issues/1226
풀 리퀘
https://github.com/onevcat/Kingfisher/pull/1220
이슈 코멘트에 따르면 수정은 된것으로 보임?
class CustomPhotoPickerViewController: TLPhotosPickerViewController {
open func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
if let image = (info[.originalImage] as? UIImage) {
var placeholderAsset: PHObjectPlaceholder? = nil
// Here!! 👇👇👇👇👇
PHPhotoLibrary.shared().performChanges({
let newAssetRequest = PHAssetChangeRequest.creationRequestForAsset(from: image)
placeholderAsset = newAssetRequest.placeholderForCreatedAsset
}, completionHandler: { [weak self] (sucess, error) in
if sucess, let `self` = self, let identifier = placeholderAsset?.localIdentifier {
extension TLPhotosPickerViewController: PHPhotoLibraryChangeObserver {
public func photoLibraryDidChange(_ changeInstance: PHChange) {
guard getfocusedIndex() == 0 else { return }
let addIndex = self.usedCameraButton ? 1 : 0
DispatchQueue.main.sync {
guard let changeFetchResult = self.focusedCollection?.fetchResult else { return }
guard let changes = changeInstance.changeDetails(for: changeFetchResult) else { return }
if changes.hasIncrementalChanges {
var deletedSelectedAssets = false
var order = 0
@tilltue
tilltue / DisposableSample.swift
Last active July 20, 2018 02:19
RxSwift : Disposable 예제 모음
func disposablesSample() {
//noOp
Observable<String>.create { (observer) -> Disposable in
observer.on(.next("observable start"))
observer.on(.next("observable end"))
return Disposables.create()
}
.subscribe().disposed(by: disposeBag)
//op
let timer = Observable<Int>.create { observer in
@tilltue
tilltue / test_AppCoordinator.swift
Created June 28, 2018 14:58
코디네이터 스냅샷 테스트
//스냅샷 테스트: 물품 목록화면
//snapshottest : coordinator (present) ListOfPurchasesViewController
func test_AppCoordinator() {
let addButtonMatcher = grey_allOf([grey_accessibilityID("addButton"),grey_sufficientlyVisible()])
EarlGrey.select(elementWithMatcher: addButtonMatcher).perform(grey_tap())
EarlGrey.select(elementWithMatcher: CustomMatcher.allOfsufficiently(id: "PriceTextField").matcher).perform(grey_replaceText("600"))
EarlGrey.select(elementWithMatcher: CustomMatcher.allOfsufficiently(id: "PurchaseInputConfirm").matcher).perform(grey_tap())
EarlGrey.select(elementWithMatcher: grey_allOf([grey_accessibilityID("ListOfPurchasesViewController"),grey_sufficientlyVisible()])).assert(grey_sufficientlyVisible())
EarlGrey.select(elementWithMatcher: addButtonMatcher).perform(grey_tap())
EarlGrey.select(elementWithMatcher: CustomMatcher.allOfsufficiently(id: "PriceTextField").matcher).perform(grey_replaceText("100"))
@tilltue
tilltue / ListOfPurchasesViewController.swift
Created June 28, 2018 14:53
뷰컨트롤러와 코디네이터 연결 부분
class ListOfPurchasesViewController: BaseTestableViewController,RxTableViewBindProtocol {
//...
var viewModel: ListOfPurchasesViewModel!
var listOfPurchasesCoordinator: ListOfPurchasesCoordinator!
}
extension ListOfPurchasesViewController {
func bindViewModel() {
//...
//UI action
protocol ListOfPurchasesCoordinatorProtocol: Coordinator {
func presentInputView()
func presentModifyView(item: Item)
func presentCustomsInformationView(viewModel: ListOfPurchasesViewModel)
}
class ListOfPurchasesCoordinator: ListOfPurchasesCoordinatorProtocol {
weak var viewController: UIViewController?
let disposeBag = DisposeBag()
@tilltue
tilltue / EarlGrey_KString.swift
Created June 26, 2018 06:20
얼그레이 한글로 객체 찾을시 공백 문제
EarlGrey.select(elementWithMatcher: Matches.displayLabel(text: "캠코더").matcher)
EarlGrey.select(elementWithMatcher: grey_text("캠코더"))
//- 요것들은 성공하지만
EarlGrey.select(elementWithMatcher: Matches.displayLabel(text: "고급 가방").matcher)
EarlGrey.select(elementWithMatcher: grey_text("고급 가방"))
//- 요건 실패한다
//공백이 있으면 찾지 못하는 듯 하다.
@tilltue
tilltue / ListOfPurchasesViewModel_Tests.swift
Last active June 3, 2019 11:18
ListOfPurchasesViewModel 1Step
//"카드 뷰모델 생성 테스트"
context("card") {
beforeEach {
self.initItems()
self.viewModel.estimatedCardViewModels
.asObservable().map{ [AnimatableSectionModel(model: "section\(0)", items: $0 )] }.debug().bind(to: self.bindProperty.bindViewModels).disposed(by: self.disposeBag)
}
it("db insert test") {
//DB에 아이템 입력시 카드 뷰모델이 생성되면 ok
let expectViewModel = PurchaseCardViewModel(item: self.item1)