Post

Replies

Boosts

Views

Activity

Reply to App crash
In your Main.storyboard, you have a scene called Favorite Reminder View Controller. There, you have two labels, one is connected to dateLabel of FavoriteReminderViewController. And the other is connected to both reminderLabel and titleLabel of FavoriteReminderViewController. But your FavoriteReminderViewController does not have a label named reminderLabel, which is causing the error: '[<RemindersApp.FavoriteReminderViewController 0x15150c2a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key reminderLabel.' You may need to remove the wrong connection by pushing × shown in the Connection Inspector.
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’21
Reply to SwiftUI: Markdown support for string variables
Is this a known bug or do I have to create an entry in Feedback Assistant? I'm not sure this would be considered to be a bug or not. When you pass a String literal for Text.init, Swift uses different initializer than passing a value of String. Structure Text Localized Strings If you initialize a text view with a string literal, the view uses the init(_:tableName:bundle:comment:) initializer, Please try this: struct MarkdownTest: View { var text: String = "**Hello** *World*" var markdownText: AttributedString = try! AttributedString(markdown: "**Hello** *World*") var keyText: LocalizedStringKey = "**Hello** *World*" var body: some View { VStack { Text("**Hello** *World*") Text(text) Text("**Hello** *World*" as String) Text(markdownText) Text(keyText) } } }
Topic: App & System Services SubTopic: General Tags:
Jun ’21
Reply to The following simple function will cause Xcode 12E262 to have "Abort: trap 6"
Thanks for sharing the info. I can reproduce the same issue with your simpler code example. May I know, why is it so? In older versions of Swift compilers, declaring exactly the same identifier in the same code block caused an error, even when one is declared with guard-let. I'm not sure why this is happening, but compilers should not stop with Abort Trap and you can send a bug report. (Showed Definition conflicts with previous value in Xcode 10.1. It is different than shadowing identifiers declared in outer scopes.) And in Xcode 13 beta, your simpler code compiles without errors. I have not tried with Xcode 12.5.1, have you tried?
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’21
Reply to How to override switch case behaviour like we override operator == with Equatable protocol
Seems Swift prefers pattern matching rather than overridden == operator when you use a value of enum with associated value. You can try something like this: extension AMInputType { public struct Matcher { fileprivate let inputType: AMInputType public init(_ inputType: AMInputType) { self.inputType = inputType } } public static func ~= (lhs: AMInputType, rhs: Matcher) -> Bool { return lhs == rhs.inputType } } func compareEnum(inputType: AMInputType) -> Bool { switch AMInputType.Matcher(inputType) { //<- case .number(.all): print("Switch case number check Successful") return true case .calender(.any): print("Switch case calender check Successful") return true case .list(.any): print("Switch case list check Successful") return true default: print("Switch case check Failed") return false } }
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’21
Reply to some symbols in sf symbol 3 can't be displayed
My Xcode is 12.5.  SF Symbols 3 is a beta version of software intended to work with beta versions of SDKs -- iOS 15 SDK, macOS 12 SDK, and so on. SF Symbols 3 These new symbols are available in apps running the beta versions of iOS 15, iPadOS 15, macOS Monterey, tvOS 15, and watchOS 8. You may need to check the Availability of each symbol if you need to target older versions of OSs.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’21
Reply to Thread 1: Swift runtime failure: Unexpectedly found nil while unwrapping an Optional value
look at the Debug navigator Debug Navigator is quite useless when finding which is being nil and you may need to modify your code: private func loadTextures() -> Textures { return Textures(loader: { name in guard let image = UIImage(named: name) else { fatalError("UIImage for \(name) cannot be created") } guard let bitmap = Bitmap(image: image) else { fatalError("Bitmap for \(name) (image: \(image)) cannot be created") } return bitmap }) } Generally, you use toooo.... many forced unwrappings (!) in your code. I recommend you to learn safe ways to work with Optionals.
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’21
Reply to Show UIImageView for 1 second and hide again
In your animation, you set alpha to 0, but there's no code to reset it to 1. func showIcon() { statusField.isHidden = false UIView.animate(withDuration: 1, delay: 0.5, options: UIView.AnimationOptions.transitionFlipFromTop, animations: { self.statusField.alpha = 0 }, completion: { finished in self.statusField.isHidden = true self.statusField.alpha = 1 //<- }) } In your shown code, showIcon() looks like it is nested inside viewDidLoad(), but it is odd and I assumed it is not nested.
Topic: UI Frameworks SubTopic: UIKit Tags:
Jun ’21
Reply to objc_getAssociatedObject and Runtime attributes
it's not being called during the XIB decoding process,  Sorry, I had not noticed the image was an example of storyboard settings. (You should better have mentioned it explicitly.) But I cannot reproduce the getters were always returning nil. I got this: Failed to set (imgAttribute) user defined inspected property on (UIImageView): [<UIImageView 0x7ff072e080f0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key imgAttribute. Not always returning nil. The User Defined Runtime Attributes uses Key Value Coding, which is one of the dynamic feature of Objective-C. Since Swift 4 (not Swift 5), you need to add an explicit annotation @objc for such methods and properties. extension UIImageView { @objc var imgAttribute: String? { get { return objc_getAssociatedObject(self, &imgAttributeKey) as? String } set { objc_setAssociatedObject(self, &imgAttributeKey, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN) } } } With this change, I can get the value shown in the User Defined Runtime Attributes: Optional("someAttr") What do you get with this change?
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’21