Skip to content

Instantly share code, notes, and snippets.

View timothycosta's full-sized avatar

Timothy Costa timothycosta

View GitHub Profile
[
{"ab":{
"title":"Abkhaz",
"nativeName":"аҧсуа"
}},
{"aa":{
"title":"Afar",
"nativeName":"Afaraf"
}},
{"af":{
@timothycosta
timothycosta / ViewController.m
Last active January 27, 2016 01:19
Cause Realm to crash when deleting an observed object during observeValueForKeyPath:
//
// ViewController.m
// RealmKVOCrash
//
// Created by Timothy Costa on 1/19/16.
// Copyright © 2016 Timothy Costa. All rights reserved.
//
#import "ViewController.h"
#import "UserProfile.h"
@timothycosta
timothycosta / ViewController.m
Created January 27, 2016 01:07
Cause Realm to crash due to "The Realm is already in a write transaction" exception
//
// ViewController.m
// RealmKVOCrash
//
// Created by Timothy Costa on 1/19/16.
// Copyright © 2016 Timothy Costa. All rights reserved.
//
#import "ViewController.h"
#import "UserProfile.h"
@timothycosta
timothycosta / gist:856afecaf4fef5dc74f323e98e8892c3
Created January 2, 2017 05:18
Object has been deleted or invalidated.
Fatal Exception: RLMException
0 CoreFoundation 0x1821821c0 __exceptionPreprocess
1 libobjc.A.dylib 0x180bbc55c objc_exception_throw
2 Realm 0x1009f6954 ___ZL17RLMAccessorGetterP11RLMProperty15RLMAccessorCode_block_invoke_2 (RLMAccessor.mm:308)
3 iLingQ 0x1001b149c __52-[FeedSearchViewController importDetailsForLessons:]_block_invoke (FeedSearchViewController.m:241)
4 Objective_Shorthand 0x1009aa198 __67-[NSArray(FunctionalMethods) arrayByTransformingObjectsUsingBlock:]_block_invoke (NSArray+FunctionalMethods.m:34)
5 CoreFoundation 0x18206f1a4 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke
6 CoreFoundation 0x18206f010 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:]
7 Objective_Shorthand 0x1009aa134 -[NSArray(FunctionalMethods) arrayByTransformingObjectsUsingBlock:] (NSArray+FunctionalMethods.m:40)
8 iLingQ 0x1001b12c
@timothycosta
timothycosta / gist:112f2eb66a2539f2d7b583f83a711edb
Created January 2, 2017 05:20
Object has been deleted or invalidated
Fatal Exception: RLMException
0 CoreFoundation 0x1841badb0 __exceptionPreprocess
1 libobjc.A.dylib 0x18381ff80 objc_exception_throw
2 Realm 0x100b6e300 RLMGetArray(RLMObjectBase*, unsigned long) (RLMAccessor.mm:212)
3 LingQ 0x1000bdaf0 -[GCCellFactory configureCell:forLesson:locked:feed:] (GCCellFactory.m:173)
4 LingQ 0x1000f0188 -[LQTableViewController configureCell:section:row:] (LQTableViewController.m:353)
5 LingQ 0x1000effec -[LQTableViewController configuredCellForTableView:row:indexPath:] (LQTableViewController.m:342)
6 LingQ 0x1000f086c -[LQTableViewController tableView:cellForRowAtIndexPath:] (LQTableViewController.m:421)
7 UIKit 0x18966f030 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:]
8 UIKit 0x18966f198 -[UITableView _createPreparedCellForGlobalRow:willDispla
@timothycosta
timothycosta / UIViewWrapper.swift
Last active February 18, 2020 21:08
Get the position of a child View by wrapping it in a UIView
//
// UIViewWrapper.swift
// lingq-5
//
// Created by Timothy Costa on 2019/06/14.
// Copyright © 2019 timothycosta.com. All rights reserved.
//
import SwiftUI
import UIKit
@timothycosta
timothycosta / UIViewController+SwiftUI.swift
Last active April 28, 2023 07:00
Using UIViewController via the SwiftUI Environment
struct ViewControllerHolder {
weak var value: UIViewController?
init(_ value: UIViewController?) {
self.value = value
}
}
struct ViewControllerKey: EnvironmentKey {
static var defaultValue: ViewControllerHolder { return ViewControllerHolder(UIApplication.shared.windows.first?.rootViewController ) }
@timothycosta
timothycosta / UIScrollViewWrapper.swift
Created July 5, 2019 03:25
UIScrollView wrapped for SwiftUI
//
// UIScrollViewWrapper.swift
// lingq-5
//
// Created by Timothy Costa on 2019/07/05.
// Copyright © 2019 timothycosta.com. All rights reserved.
//
import SwiftUI
@timothycosta
timothycosta / CADisplayLinkBinding.swift
Last active April 3, 2020 00:43
A CADisplayLink in a BindableObject
//
// CADisplayLinkBinding.swift
// lingq-5
//
// Created by Timothy Costa on 2019/07/11.
// Copyright © 2019 timothycosta.com. All rights reserved.
//
import Combine
import SwiftUI
@timothycosta
timothycosta / GeometryFinder.swift
Created July 11, 2019 03:41
Find the geometry of a SwiftUI View
//
// GeometryFinder.swift
//
// Created by Timothy Costa on 2019/06/24.
// Copyright © 2019 timothycosta.com. All rights reserved.
//
import SwiftUI
struct RectPreferenceKey: PreferenceKey {