Post

Replies

Boosts

Views

Activity

Reply to Core data Array and Conforming to NSSecureCoding
Sorry, not tested, but I would write something like this, if I want to store [CNLabeledValueCNPhoneNumber] (ArrayCNLabeledValueCNPhoneNumber): class PhoneNumbersToDataTransformer: NSSecureUnarchiveFromDataTransformer { override class func allowsReverseTransformation() - Bool { return true } override class func transformedValueClass() - AnyClass { return NSArray.self //- } override class var allowedTopLevelClasses: [AnyClass] { return [CNLabeledValueCNPhoneNumber.self, NSArray.self, CNPhoneNumber.self] //- } override func transformedValue(_ value: Any?) - Any? { guard let data = value as? Data else { fatalError("Wrong data type: value must be a Data object; received \(type(of: value))") } return super.transformedValue(data) } override func reverseTransformedValue(_ value: Any?) - Any? { guard let phone = value as? [CNLabeledValueCNPhoneNumber] else { fatalError("Wrong data type. Received \(type(of: value))") } return super.reverseTransformedValue(phone) } } (In transformable attribute, the Custom Class needs to be a descendant of NSObject, in your case, it would be NSArray.) Can you try and tell us what you get?
Feb ’21
Reply to Need Assistance with sending attachments for MFMessageComposeViewController
FreshImage1, FreshImage2, and FreshImage3 refer to the types of images As far as I see your code, freshImage1, freshImage2 and freshImage3 are UIImageView, not images. I strongly recommend you not to use UIImageView as a storage of image. if any less than three photos are available when "Submit Now" is pressed, then the app crashes You are using many crash my app operators (!) , and that why your app crashes. Stop using crash my app operators.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’21
Reply to Unable to simultaneously satisfy constraints.
there is something we, developers, can do It happens deep within the implementation of SwiftUI, so there's nothing we can do. You can find some (many?) reports about the same warning in SwiftUI, but I cannot find any definite answers to solve them. Better ignore it (or just send a feedback to Apple) unless your code causes some broken layout.
Topic: Programming Languages SubTopic: Swift Tags:
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
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 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 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 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