Skip to content

Commit

Permalink
Unowned self reference crashed on iOS 13 (#2008)
Browse files Browse the repository at this point in the history
  • Loading branch information
mats-claassen committed Mar 24, 2020
1 parent 5406bdb commit 41bbb0a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
22 changes: 9 additions & 13 deletions Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "51729E191B9A54F1004A00EB"
BuildableName = "Example.app"
BlueprintName = "Example"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -39,17 +48,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "51729E191B9A54F1004A00EB"
BuildableName = "Example.app"
BlueprintName = "Example"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -71,8 +69,6 @@
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
12 changes: 6 additions & 6 deletions Source/Core/RowType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ extension RowType where Self: BaseRow {
*/
@discardableResult
public func onChange(_ callback: @escaping (Self) -> Void) -> Self {
callbackOnChange = { [unowned self] in callback(self) }
callbackOnChange = { [weak self] in callback(self!) }
return self
}

Expand All @@ -213,7 +213,7 @@ extension RowType where Self: BaseRow {
*/
@discardableResult
public func cellUpdate(_ callback: @escaping ((_ cell: Cell, _ row: Self) -> Void)) -> Self {
callbackCellUpdate = { [unowned self] in callback(self.cell, self) }
callbackCellUpdate = { [weak self] in callback(self!.cell, self!) }
return self
}

Expand All @@ -224,7 +224,7 @@ extension RowType where Self: BaseRow {
*/
@discardableResult
public func cellSetup(_ callback: @escaping ((_ cell: Cell, _ row: Self) -> Void)) -> Self {
callbackCellSetup = { [unowned self] (cell: Cell) in callback(cell, self) }
callbackCellSetup = { [weak self] (cell: Cell) in callback(cell, self!) }
return self
}

Expand All @@ -235,7 +235,7 @@ extension RowType where Self: BaseRow {
*/
@discardableResult
public func onCellSelection(_ callback: @escaping ((_ cell: Cell, _ row: Self) -> Void)) -> Self {
callbackCellOnSelection = { [unowned self] in callback(self.cell, self) }
callbackCellOnSelection = { [weak self] in callback(self!.cell, self!) }
return self
}

Expand All @@ -246,13 +246,13 @@ extension RowType where Self: BaseRow {
*/
@discardableResult
public func onCellHighlightChanged(_ callback: @escaping (_ cell: Cell, _ row: Self) -> Void) -> Self {
callbackOnCellHighlightChanged = { [unowned self] in callback(self.cell, self) }
callbackOnCellHighlightChanged = { [weak self] in callback(self!.cell, self!) }
return self
}

@discardableResult
public func onRowValidationChanged(_ callback: @escaping (_ cell: Cell, _ row: Self) -> Void) -> Self {
callbackOnRowValidationChanged = { [unowned self] in callback(self.cell, self) }
callbackOnRowValidationChanged = { [weak self] in callback(self!.cell, self!) }
return self
}
}

0 comments on commit 41bbb0a

Please sign in to comment.