Skip to content

Commit

Permalink
added extra checks for main thread, and some badges to README
Browse files Browse the repository at this point in the history
  • Loading branch information
maxxfrazer committed Apr 5, 2020
1 parent b022377 commit 44854c3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

RKPointPin is a UIView which sticks to an `ARView` and points at a chosen entity within the scene, with options to hide the pin when near the center of the screen, or perform any custom actions.

[![Swift Package Manager](https://img.shields.io/badge/Swift_Package_Manager-v1.0.0-orange.svg?style=flat)](https://github.com/apple/swift-package-manager)
[![Swift 5.2](https://img.shields.io/badge/Swift-5.2-orange.svg?style=flat)](https://swift.org/)

![RKPointPin Example](media/pin_512.gif)

## Minimum Requirements
Expand Down Expand Up @@ -29,4 +32,4 @@ self.arView.addSubview(rkPin)
rkPin.targetEntity = boxEntity
```

By default the RKPointPin will be visible all the time, but if you want the pin to hide when in the center, set the `focusPercentage` to a value ranging from 0 to 1. If `focusPercentage` is set to 1, then the pin will only appear when the `targetEntity` is outside of the view, as everything from the edges inwards is considered the focus area.
By default the RKPointPin will be visible all the time, but if you want the pin to hide when in the center, set the `focusPercentage` to a value ranging from 0 to 1. If `focusPercentage` is set to 1, then the pin will only appear when the `targetEntity` is outside of the view, as everything from the edges inwards is considered the focus area.
11 changes: 9 additions & 2 deletions Sources/RKPointPin/RKPointPin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,14 @@ public class RKPointPin: UIView {

private func resetCancellable() {
self.cancellable?.cancel()
guard let arView = self.arView, self.targetEntity != nil else {
if self.targetEntity == nil {
return
}
if !Thread.isMainThread {
print("RKPointPin ERROR: targetEntity should set from main thread")
return
}
guard let arView = self.arView else {
return
}
self.cancellable = arView.scene.subscribe(
Expand Down Expand Up @@ -168,7 +175,7 @@ public class RKPointPin: UIView {

private func updatePos() {
if !Thread.isMainThread {
print("RKPointPin: Should be on main thread")
print("RKPointPin ERROR: Should be on main thread")
return
}
guard let arView = self.arView else {
Expand Down

0 comments on commit 44854c3

Please sign in to comment.