Post

Replies

Boosts

Views

Activity

Reply to How can I auto-populate a Text Field once a button is selected?
You declare a local constant within offlineListing(_:), but it is not used and the value is disposed at the end of the method. (You would have seen a waring Initialization of immutable value 'productURLField' was never used; consider replacing with assignment to '_' or removing it, which should not be ignored.) Even if the local constant and the IBOutlet have exactly the same identifier, they are two different things and have nothing to do with each other. You may want to do something like this: @IBAction func offlineListing(_ sender: Any) { productURLField.text = "N/A" }
Topic: UI Frameworks SubTopic: UIKit Tags:
May ’21
Reply to Need help converting JSON objects from double & floats to strings
As already noted, when you need to convert Float/Double to String for assignment, you need to do it in the right hand side. So, this would be the minimal code: func connectLabels(loc: String, temp: Double, lat: Float, long: Float) { locationLabel.text = loc tempInFLabel.text = String(temp) latLabel.text = String(lat) longLabel.text = String(long) } But if you want to make your app sort of practical in the future, you should better use NumberFormatter for user readable values. Also, some users want temperatures shown in the unit they accustomed to, we use Celsius usually. So, some practical code would be something like this: static let tempFormatter: MeasurementFormatter = { let mf = MeasurementFormatter() //You may want to modify these as you like... mf.unitStyle = .medium mf.numberFormatter.maximumFractionDigits = 1 return mf }() static let latLongFormatter: NumberFormatter = { let nf = NumberFormatter() //You may want to modify these as you like... nf.usesSignificantDigits = true nf.minimumSignificantDigits = 5 nf.maximumSignificantDigits = 5 return nf }() func connectLabels(loc: String, temp: Double, lat: Float, long: Float) { locationLabel.text = loc let tempMeasurement = Measurement(value: temp, unit: UnitTemperature.fahrenheit) tempLabel.text = MyWeatherTableViewCell.tempFormatter.string(from: tempMeasurement) latLabel.text = MyWeatherTableViewCell.latLongFormatter.string(from: lat as NSNumber) longLabel.text = MyWeatherTableViewCell.latLongFormatter.string(from: long as NSNumber) }
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to How to access viewController components in model (MVC)
Okay, and do you have any idea how I can do that? Or a resource, a link to help me?  You can make your Model to trigger some events, and your view controller will be able to show UIAlertController or update text view based on the evens. To achieve this, you can use NotificationCenter, property observer, delegate pattern or there may be many other ways. Combine would be your another option if you prefer some modern ways. But, as you say Compute class is empty, I cannot say what would be best for you and cannot show any examples.
Topic: UI Frameworks SubTopic: UIKit Tags:
Jun ’21
Reply to iOS app development
Is Python usable to make iOS apps on Mac in 2021 or only Swift? Swift and Objective-C are the only supported languages for developing iOS apps. (C/C++ could be another option for some specific components of Apple's platforms.) And Xcode (more specifically, version 12+) is the only supported IDE to make apps for App Store. You can find some third party frameworks or tools which enable you to develop iOS apps in JavaScript, Dart, C#, Ruby or Python. (It is very hard to find articles about developing iOS apps in Python, which seems to be a very minor choice.) If you want to use any of such frameworks, you need to know the risks of using them. For example, there were several posts recently, reporting they could not build their apps made by one of the third party frameworks. Also the Apple's dev forums are meant for code-level questions, using Apple's framework or tools for Apple's platforms. You should not go deep into the third party libraries or frameworks here in the dev forums. My recommendation, get the latest Mac which is capable of running the latest Xcode. And learn developing apps in Swift.
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’21
Reply to Xcode Cannot Run the Default "Hello World" C++ Program
Any idea why this is happening? I have tried what you described using Xcode 12.5 on macOS 11.4. It ran without any problems and I could see in the debug console: Hello, World! Program ended with exit code: 0 Thus, there may be some issues with your environment, or macOS 11.2 may have some problems to work with the version of Xcode you are using. Do you think of anything special with your environment?
Jun ’21
Reply to Swift migration failed Segmentation fault: 11
Unfortunately, there's no quick fix for Segmentation fault: 11. In some limited cases, Clean Build Folder or removing derived data might work, but not for all cases. The first thing you should do is finding out which Swift file is (or which Swift files are) causing the issue. How many Swift files do you have in your project?
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’21
Reply to 2021-6 Missing Info.plist value - A value for the Info.plist key 'CFBundleIconName' is missing in the bundle, even then I include CFBundleIconName.
Have you added app icons in an asset catalog as suggested in the Apple's message? Apps built with iOS 11 or later SDK must supply app icons in an asset catalog and must also provide a value for this Info.plist key. For more information see http://help.apple.com/xcode/mac/current/#/dev10510b1f7.
Jun ’21