Post

Replies

Boosts

Views

Activity

Reply to My app stops in Simulator
The code is good and does not show any error.  No, the code may compile and build an app but not be good. But, without getting more precise information, and without seeing code, very hard to say. Is it a SwiftUI or a UIKit app ? At least, post the Swift AppDelegate file and the Swift SceneDelegate file. Could you post the project somewhere or provide an email address to allow to share files ? the app stops working or displays a black screen. When the app starts before stopping, what do you get ? Have you a launch screen, do you see it before app turning black ?
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21
Reply to How to create two distinct types of users in an application who interact with one another?
If you want to create 2 types of users with different rights or roles, you'll probably have to register them on your server (a self declaration isn't robust enough). Then, once user gets its credential, he/she will have access to some functions. Then interaction could go through your server. Take care to read carefully the Appstore guidelines, to check what you're authorised to do. If there is some commercial transaction, that needs to go through the Appstore.
Topic: App & System Services SubTopic: Core OS Tags:
Mar ’21
Reply to setAlternateIconName with nothing changed
Your code was not completely formatted. In which func is this part of code called ? if ([[UIApplication sharedApplication] supportsAlternateIcons]) { NSString *name = [UIApplication sharedApplication].alternateIconName; if (name&&[name isEqualToString:@"changeicon"]) { [[UIApplication sharedApplication] setAlternateIconName:nil completionHandler:^(NSError * _Nullable error) { }]; } else { [[UIApplication sharedApplication] setAlternateIconName:@"changeicon" completionHandler:^(NSError * _Nullable error) { }]; } } } Could you log the error lines 5 and 9 ? and add a NSLog to check which branch of the if / else is used. Line 4, if name isEqualToString:@"changeicon" (which should always be true), then you return to app's primary icon. Is it intentional ? AFAIU, you should systematically execute line 4 and never 8.
Topic: UI Frameworks SubTopic: UIKit Tags:
Mar ’21
Reply to Developing on iPad
Did you try with UIImage(named: "image.jpg"), after copying the image in Resources ? Look here: https://stackoverflow.com/questions/24069479/swift-playgrounds-with-uiimage or here: https://developer.apple.com/forums/thread/667024
Mar ’21
Reply to Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
Look at this: class ViewController: UIViewController, UITextFieldDelegate { @IBOutlet weak var weightInput: UITextField! @IBOutlet weak var heightInput: UITextField! @IBOutlet weak var BMIOutput: UITextField! @IBOutlet weak var categoryOutput: UILabel! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. self.weightInput.delegate = self //added either ! or ? here and don't get fatal error self.heightInput.delegate = self //added either ! or ? here and don't get fatal error } Line 2 you declare an IBOutlet, as implicitly unwrap. That means that weightInput is an optional, so either nil or some value. Implicitly unwrap means that if you call it once it has a value, you don't need to unwrap anymore. It is done implicitly. But, if you call when it is not initialized (nil) and try to unwrap, of course you crash. And an IBOutlet is loaded and initialized when the view is loaded. But the IBOulet var is initialized only if it is properly connected to the object in storyboard. Otherwise, no way to know which var to initilize, hence it remains nil. So most likely in your case, the connection between th IBOutlet and the TextField in storyboard is not set or is broken. Then, when you call line 10: self.weightInput.delegate = self Do you see a black dot on the left of @IBOutlet weak var weightInput: UITextField! If not, control drag from the white circle to the textField in storyboad. The connection will be made, and crash will disappear (if you do it for all IBOutlets). Note: you wrote: The code builds in both cases and only produces a Fatal Error when I run the simulator without the unwrapping tags. With the unwrapping added the simulator runs, but when I enter the data and click on the link nothing appears in the MY BMI text box. It is logical not to crash with ?, but a bit surprising you do not crash with ! If weightInput is nil, when you set with optional chaining self.weightInput?.delegate = self in fact it does nothing (execution "halted" after ? because of nil). TextField appear on screen, you can type, but delegate functions (as textFieldShouldReturn) are not called. Nothing appears in the MY BMI text
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21
Reply to Run something before another thing
I need the function to run before it sets the text. Which function ? You don't show anything about it. How do you want anyone to guess ? Please, explain properly what you need and provide relevant information, otherwise, it is impossible to help.
Topic: UI Frameworks SubTopic: UIKit Tags:
Mar ’21
Reply to JSON Core Data favorites
If I understand your question correctly. You have 2 things : the data for all the information you save in Core Data the status of some as favorite. This may be stored in the core data or simpler in suerSettings (with a reference to the data ID)
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21
Reply to Pass Data Forward Tips
That's not totally clear… without pushing my initial viewcontroller? What do you mean ? What is the problem with push ? Did you consider using a modal segue for instance of a popover ? Or embedding your first VC in a navigation controller ?
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21