Post

Replies

Boosts

Views

Activity

Reply to access the uuid property in query
Why don't you simply access the property uuid? for result in results as! [HKQuantitySample] { let uuid = result.uuid print(uuid) let bloodGlucose = result.quantity.description //... } By the way, what is the type of results? You should better avoid risky forced casting as! as far as you can.
Topic: Programming Languages SubTopic: Swift Tags:
Feb ’21
Reply to XCode
here's my code :) Thanks. It's a little bit far from I imagined... It should be something like this: #include stdio.h #include string.h char *strrev(char *word) { //... - You need to implement `strrev` by yourself } int main(int argc, const char * argv[]) { char word[100]; char words[100]; printf("Input your word:"); gets(word); //- `gets` is unsafe. Better not use it. strcpy(words,word); printf("Reversed:"); printf("%s\n", strrev(words)); if( strcmp(word,words) == 0 ) { printf("It is a palindrome word\n"); } else { printf("It is not a palindrome word\n"); } return 0;, } If you want to practice C-programming with Xcode, you should better find a better textbook which is written for Standard C.
Feb ’21
Reply to progress bar will not work
Initializer 'init(value:total:)' requires that 'BindingInt' conform to 'BinaryFloatingPoint' Thanks for showing the error message. That will help readers find what's happening in your code. The initializer of ProgressView you are trying has this signature: initV(value: V?, total: V = 1.0) where Label == EmptyView, CurrentValueLabel == EmptyView, V : BinaryFloatingPoint The value passed to value: needs to be of some type BinaryFloatingPoint, not Binding nor Int. struct ContentView: View { @State private var progress: Double = 0 //- A type conforming to `BinaryFloatingPoint` var body: some View { ProgressView(value: progress) //- No `$` here } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’21
Reply to Can't Figure Out How to Use Function
Any thoughts? Assume you want to call this isDateInToday(_:): isDateInToday(_:) - https://developer.apple.com/documentation/foundation/calendar/2293243-isdateintoday (When you ask something about functions defined in a framework, you should better include a link to the doc of it.) In this case, isDateInToday is an instance method. When you want to call an instance method of some other type, you need to prefix instanceName: instanceName.isDateInToday(oneTimeDate) The instance needs to be of type Calendar, you can get the instance of the user's current Calendar with Calendar.current: struct OneTimeRow: View { let calendar = Calendar.current //- An instance of `Calendar` //...     var body: some View { //... if calendar.isDateInToday(oneTimeDate) { Text("Today at \(oneTimeDate, formatter: itemFormatter)") } else if calendar.isDateInYesterday(oneTimeDate) { //- `isDateInYesterday`, not `isDateinYesterday` Text("Yesterday at \(oneTimeDate, formatter: itemFormatter)") } else if calendar.isDateInTomorrow(oneTimeDate) { Text("Tomorrow at \(oneTimeDate, formatter: itemFormatter)") } else { //... } //... } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’21
Reply to Get Xcode 9 for macOS High Sierra 10.13.6
You can find old Xcodes on the More Downloads page - https://developer.apple.com/download/more/. (You may need to scroll down long.) The latest version of Xcode for macOS 10.13.6 is 10.1 based on the Xcode wiki - https://en.wikipedia.org/wiki/Xcode. Anyway, neither 9 nor 10,1 can build apps for App Store, are you OK with that?
Feb ’21
Reply to Clickable Tinder Style Cards SwiftUI
Your code contains many missing parts -- Shop, AnyTransition.trailingBotton, CardView, zoopeData, ProductDetailView and sampleClothes, or possibly more. If you could show buildable, simplified, but enough to reproduce the issue, I (and many readers) would examine it. One thing to note, having Views in an @State variable would be a bad design in SwiftUI in almost all cases. Just hold a model enough to represent CardView, and construct CardView inside body using the model.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’21