Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. struct Beacon: Hashable, Codable, Identifiable {
  2. var id: Int
  3. ...
  4. var beaconadv: BeaconAdv
  5. ...
  6. }
  7.  
  8. struct BeaconAdv: Hashable, Codable {
  9. ...
  10. var booltest: Bool?
  11. ...
  12. }
  13.  
  14. final class UserData: BindableObject {
  15.  
  16. let willChange = PassthroughSubject<UserData, Never>()
  17.  
  18. var showFavoritesOnly = false {
  19. willSet {
  20. willChange.send(self)
  21. }
  22. }
  23.  
  24. var showOtherBeacons = true {
  25. didSet {
  26. willChange.send(self)
  27. }
  28. }
  29.  
  30. var updateBeaconDetails = true {
  31. didSet {
  32. willChange.send(self)
  33. }
  34. }
  35.  
  36. var beacons = beaconData {
  37. didSet {
  38. willChange.send(self)
  39. }
  40. }
  41. }
  42.  
  43. let beaconData: [Beacon] = load("beaconDataTest.json")
  44.  
  45. private var centralManager : CBCentralManager!
  46. private var locationManager : LocationManager!
  47. var userData: UserData!
  48.  
  49. public func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
  50.  
  51. struct BeaconDetail: View {
  52. @EnvironmentObject var userData: UserData
  53. ...
  54. var body: some View {
  55. VStack {
  56. List {
  57.  
  58. Section() {
  59. if self.userData.beacons[self.beaconIndex].beaconadv.booltest != nil {
  60. if self.userData.beacons[self.beaconIndex].beaconadv.booltest! {
  61. Text("booltest = true")
  62. } else {
  63. Text("booltest = false")
  64. }
  65. } else {
  66. Text("booltest = nil")
  67. }
  68. }
  69. ...
  70. }
  71. ... .navigationBarTitle(Text(self.userData.beacons[self.beaconIndex].name), displayMode: .inline)
  72. .background(Color.white)
  73. .listStyle(.grouped)
  74. }
  75. }
  76.  
  77. Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1d3b0b690)
  78.  
  79. @UIApplicationMain
  80. class AppDelegate: UIResponder, UIApplicationDelegate {
  81.  
  82. func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
  83. // Override point for customization after application launch.
  84.  
  85. return true
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement