Post

Replies

Boosts

Views

Activity

I need to create Swift Charts using Sensor data
I have created Swift Charts using Ready Made Data Like below static let last12Months = [ (month: date(year: 2022, month: 6), KW: 3952, dailyAverage: 127, dailyMin: 95, dailyMax: 345), (month: date(year: 2022, month: 7), KW: 8322, dailyAverage: 124, dailyMin: 55, dailyMax: 255), (month: date(year: 2022, month: 8), KW: 2952, dailyAverage: 245, dailyMin: 99, dailyMax: 673), (month: date(year: 2022, month: 9), KW: 3352, dailyAverage: 875, dailyMin: 92, dailyMax: 623), (month: date(year: 2022, month: 10), KW: 3252, dailyAverage: 257,dailyMin: 55, dailyMax: 675), (month: date(year: 2022, month: 11), KW: 3232, dailyAverage: 537,dailyMin: 65, dailyMax: 643), (month: date(year: 2022, month: 12), KW: 9871, dailyAverage: 253,dailyMin: 25, dailyMax: 987), (month: date(year: 2023, month: 1), KW: 8623, dailyAverage: 235, dailyMin: 96, dailyMax: 353), (month: date(year: 2023, month: 2), KW: 7612, dailyAverage: 276, dailyMin: 64, dailyMax: 765), (month: date(year: 2023, month: 3), KW: 2335, dailyAverage: 978, dailyMin: 36, dailyMax: 456), (month: date(year: 2023, month: 4), KW: 9087, dailyAverage: 667, dailyMin: 63, dailyMax: 675), (month: date(year: 2023, month: 5), KW: 2823, dailyAverage: 865, dailyMin: 100, dailyMax: 765), (month: date(year: 2023, month: 6), KW: 9762, dailyAverage: 544, dailyMin: 36, dailyMax: 999), ] `but now I want to create same charts with real world reading like Health App. For example aim taking the sensor value through bluetooth, I can show the reading from sensor to app but how can I store the data for months and show them in Charts Any Ideas where am I lagging`
0
0
598
Jun ’23
How to move the Gauge Indicator with Animation
I wanted to make a Gauge View to display the angle Moved below is the image and the needle give the angle according to the input is given ,but I need to change the direction of the needle with some animation as of now its just moving like a glitch below is my code import SwiftUI struct RudderView: View {     @State var ArrowValue: CGFloat = -100     let AngleTimer = Timer.publish(every: 0.1, on: .main, in: .common).autoconnect()     var body: some View {         NavigationView {             ZStack{                     Circle()                         .stroke(.gray.opacity(0.1),lineWidth: 25)                     Circle()                         .trim(from: 0,to: 0.75)                         .stroke(Gradient(colors: [.red,.white,.green]), style: StrokeStyle(lineWidth: 25,lineCap: .round,lineJoin: .round))                         .rotationEffect(Angle(degrees: -225))                                   ZStack {                         RoundedRectangle(cornerRadius: 20)                             .foregroundColor(.white)                             .frame(width: 25, height: 150)                     }                     .offset(x:0, y: -50)                     .rotationEffect(Angle(degrees: ArrowValue))                     .onReceive(AngleTimer) { _ in                         withAnimation {                                                              }                         }                     }                     Text("40")                         .font(.largeTitle)                         .fontWeight(.thin)                         .foregroundColor(.white)                         .offset(x:100, y:170)                     Text("-40")                         .font(.largeTitle)                         .fontWeight(.thin)                         .foregroundColor(.white)                         .offset(x:-100, y:170)             }             .padding()         }                      }             } struct RudderView_Previews: PreviewProvider {     static var previews: some View {         RudderView()             .preferredColorScheme(.dark)     }]w } can anyone say what to type in the animation bracket to move my needle smoothly according to the changes of input for arrow
0
0
1.1k
Mar ’23
I need to read multiple Queries of HKStatisticsCollectionQuery Like StepCount and Swimming Stroke
This is the the func for Authorisation from health App func stepCount(completion: @escaping (Bool) -> Void){ if HKHealthStore.isHealthDataAvailable(){ let stepCount = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.stepCount)!  let swimmingStrokeCount = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.swimmingStrokeCount)!   guard let healthStore = self.healthStore else { return completion(false) }   healthStore.requestAuthorization(toShare: [], read: [swimmingStrokeCount,stepCount]) { (success, error) in completion(success)             }   }     } and then Im not able to read both step count and swimming Stroke at the the same query func readData(completion: @escaping (HKStatisticsCollection?)-> Void){         let stepCount = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.stepCount)!         let swimmmingStrokeCount = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.swimmingStrokeCount)!         let startDate = Calendar.current.date(byAdding: .day,value: -7, to: Date())         let anchorDate = Date.monday12AM()         let daily = DateComponents(day : 1)         let predicate = HKQuery.predicateForSamples(withStart: startDate, end: Date(), options: .strictStartDate)         query = HKStatisticsCollectionQuery(quantityType: stepCount, quantitySamplePredicate: predicate,options: .cumulativeSum, anchorDate: anchorDate, intervalComponents: daily)         query1 = HKStatisticsCollectionQuery(quantityType: swimmmingStrokeCount, quantitySamplePredicate: predicate,options: .cumulativeSum, anchorDate: anchorDate, intervalComponents: daily)         query!.initialResultsHandler = { query, statisticsCollection, error in             completion(statisticsCollection)         } if let healthStore = healthStore, let query = self.query {             healthStore.execute(query)         }     } is there any possible way to call both query and query1 as a single query also I have tried to call them entirely separate as two different queries but that too is not working as expected it results becomes sum of step count and swimming stroke can anyone clear my doubt?
1
0
919
Mar ’23
I want to use HKStatisticsQuery to read the Active Energy Burned from HealthKit
I have requested the access from the HealthKit by below code let calorieCount = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.activeEnergyBurned)! and it working perfectly but not able to read the data using Query after reading the documentation I have found out HKStatisticsQuery is used for Query     func CaloriesBurned() {         let activeEnergy = HKQuantityType.quantityType(forIdentifier: .activeEnergyBurned)!         let startDate = Calendar.current.date(byAdding: .day,value: -7, to: Date())         let predicate = HKQuery.predicateForSamples(withStart: startDate, end: Date(), options: .strictStartDate)         let query = HKStatisticsQuery(quantityType: activeEnergy, quantitySamplePredicate: predicate,completionHandler: <#T##(HKStatisticsQuery, HKStatistics?, Error?) -> Void#>))     } but I don't understand what should be written in completion handler in above code to read the active Energy Burned I have read already documentation if anyone has sample code to read energy burned or sample code on how to use HKStatisticsQuery
1
0
911
Jan ’23
Cannot convert value of type 'Set<HKQuantityType>' to expected argument type 'HKQuantityType
below is my code of reading data from HealthKit for Multiple Data but for reading Multiple data using Set() it shows "Cannot convert value of type 'Set' to expected argument type 'HKQuantityType' " func readData(completion: @escaping (HKStatisticsCollection?)-> Void){         let stepCount = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.stepCount)!         let MoveCount = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.appleMoveTime)!         let DistanceCount = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.distanceWalkingRunning)!         let Activitysummary = Set([stepCount,MoveCount,DistanceCount])                  let startDate = Calendar.current.date(byAdding: .day, value: -7, to: Date())         //MARK: here we setting our start time at 12.00 AM         let anchorDate = Date.monday12AM()         //MARK: we going to calculate the value for each day         let daily = DateComponents(day : 1)         let predicate = HKQuery.predicateForSamples(withStart: startDate, end: Date(), options: .strictStartDate)         //MARK: .cummulativesum -> iPhone and Apple Watch Difference         query =  HKStatisticsCollectionQuery(quantityType: Activitysummary, quantitySamplePredicate: predicate,options: .cumulativeSum, anchorDate: anchorDate, intervalComponents: daily) //MARK: here in ActivitySummary it show the error                  query!.initialResultsHandler = { query,statisticsCollection, error in             completion(statisticsCollection)         }         if let healthStore = healthStore, let query = self.query{             healthStore.execute(query)         }     }
3
0
2.4k
Jan ’23
Im interested to make HomeKit enabled accessory
As I’m interested to make HomeKit accessory while searching in the internet i found out that hobbyist can make HomeKit accessary without MFI license the link is given below https://mfi.apple.com/en/who-should-join.html but it says to download HAP Specification which is pdf containing all the information regarding interacting with Apple devices with HomeKit Accessories but im not able to see any pdf in the give link can anyone say where will be the pdf is present to download Thank you in advance
2
0
957
Jan ’23
Missing required column 'label' in json. at "HandPoseAssests.json"
I have created the .json file according to the https://developer.apple.com/documentation/createml/building-an-object-detector-data-source here is my .json file below     {         "imagefilename":"Five Fingers.HEIC",         "annotation": [             {                 "coordinates": {                     "y": 156.062,                     "x": 195.122,                     "height": 148.872,                     "width": 148.03                 },                 "label": "Five Fingers"             }         ]     },     {         "imagefilename": "One Finger.HEIC",         "annotation": [             {                 "coordinates": {                     "y": 156.062,                     "x": 195.122,                     "height": 148.872,                     "width": 148.03                 },                 "label": "One Finger"             }         ]     },     {         "imagefilename": "Two Finger.HEIC",         "annotation": [             {                 "coordinates": {                     "y": 156.062,                     "x": 195.122,                     "height": 148.872,                     "width": 148.03                 },                 "label": "Two Finger"             }         ]     },     {         "imagefilename": "Four Finger.HEIC",         "annotation": [             {                 "coordinates": {                     "y": 156.062,                     "x": 195.122,                     "height": 148.872,                     "width": 148.03                 },                 "label": "Four Finger"             }         ]     }     ] but it shows error as Missing required column 'label' in json. at "NameOfJsonFile.json" Were am I Wrong
2
0
1.2k
Dec ’22
cannot find 'minutes' in the scope
im getting this error after this code, what module should Iimport here? or does it causes any other problem? //  ContentView.swift //  Widget_and_LiveActivities // //  Created by Makwin Santhosh K on 20/11/22. // import SwiftUI import ClockKit struct ContentView: View {     var body: some View {         var future = Calendar.current.date(byAdding: .minute, value: (Int(minutes) ?? 0), to: Date())! // here is where im getting (cannot find 'minutes' in the scope)         future = Calendar.current.date(byAdding: .second, value: (Int(seconds) ?? 0), to: future)! // also where is where im getting (cannot find 'seconds' in the scope)         let date = Date.now...future         let updatedDeliveryStatus = PizzaDeliveryAttributes.PizzaDeliveryStatus(driverName: "Anne Johnson", deliveryTimer: date)         let alertConfiguration = AlertConfiguration(title: "Delivery Update", body: "Your pizza order will arrive in 25 minutes.", sound: .default)         await deliveryActivity?.update(using: updatedDeliveryStatus, alertConfiguration: alertConfiguration)                           let initialContentState = PizzaDeliveryAttributes.ContentState(driverName: "Bill James", deliveryTimer:date)         let activityAttributes = PizzaDeliveryAttributes(numberOfPizzas: 3, totalAmount: "$42.00", orderNumber: "12345")         do {             deliveryActivity = try Activity.request(attributes: activityAttributes, contentState: initialContentState)             print("Requested a pizza delivery Live Activity \(String(describing: deliveryActivity?.id)).")         } catch (let error) {             print("Error requesting pizza delivery Live Activity \(error.localizedDescription).")         }     } } struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView()     } } // this is the example code from [https://developer.apple.com/documentation/activitykit/displaying-live-data-with-live-activities)
7
0
2.1k
Nov ’22
Button to navigate through SwiftUI Views
this is my code I need my toolBar buttons to navigate to other SwiftUi views what should I write in button action { } to open the other SwiftUi View //  SwiftLoginView.swift //  Login FireBase // //  Created by Makwin Santhosh K on 08/11/22. // import SwiftUI import MapKit import CoreLocationUI struct OverallView: View {     var body: some View{                  NavigationView {             ZStack{                                  ToolBarShape()                     .frame(width: 400,height: 110)                     .foregroundColor(.white)                     .shadow(radius: 6)                     .offset(x : 0, y: 410)                                                     .toolbar {                         ToolbarItemGroup(placement: .bottomBar){                             //MARK: Button Home                             Button(action :{                                                              }, label:{                                 VStack {                                     Image(systemName: "house")                                     Text("Home")                                 }                                 .font(.footnote)                                 .foregroundColor(.black)                                                              })                             Spacer()                             //MARK: Button Money                             Button(action :{                                                            },label:{                                 VStack {                                     Image(systemName: "dollarsign")                                     Text("Money")                                 }                                 .font(.footnote)                                 .foregroundColor(.black)                                                              })                             Spacer()                             //MARK: Button Home                             Button(action :{                                                              },label:{                                 VStack {                                     Image(systemName: "person")                                     Text("Help")                                 }                                 .font(.footnote)                                 .foregroundColor(.black)                                                                                               })                             //MARK: Button Home                             Spacer()                             Button(action :{                                                              },label:{                                 VStack {                                     Image(systemName: "menubar.rectangle")                                     Text("More")                                 }                                 .font(.footnote)                                 .foregroundColor(.black)                                                                                               })                                                                                   }                                              }             }         }     } }      struct MapUView: View {     @StateObject public var ViewModel = ContentViewModal()          var body: some View {         ZStack(alignment: .bottom) {             AreaMap(region: $ViewModel.region)                          LocationButton(.currentLocation){                 ViewModel.requestUserLocationForOnce()             }             .foregroundColor(.white)             .cornerRadius(8)              }     }                                   struct AreaMap: View {         @Binding var region: MKCoordinateRegion                  var body: some View {             let binding = Binding(                 get: { self.region },                 set: { newValue in                     DispatchQueue.main.async {                         self.region = newValue                     }                 }             )             return Map(coordinateRegion: binding, showsUserLocation: true)                 .ignoresSafeArea()         }     }               final class ContenViewModal: NSObject, ObservableObject, CLLocationManagerDelegate{         @Published var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 20, longitude: 90), span: MKCoordinateSpan(latitudeDelta: 100, longitudeDelta: 100))         let locationManager = CLLocationManager()                  override init() {             super.init()             locationManager.delegate = self         }                  func requestUserLocationForOnce() {             locationManager.requestLocation()         }                  func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {             guard let latestLocation = locations.first else {                 //show error                 return             }             self.region = MKCoordinateRegion(center: latestLocation.coordinate, span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05))         }                  func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {             print(error.localizedDescription)         }     } } struct OverallView_Previews: PreviewProvider {     static var previews: some View {         OverallView()     } }
5
0
4.4k
Nov ’22