Post

Replies

Boosts

Views

Activity

Reply to error during division please help me
You are dividing two integers. When the computer divides two integers, it removes the remainder. That is why you get 12.0 when you divide 25 by 2 instead of 12.5. Convert the integers to Double before doing the division to get the correct value when dividing. See the following Stack Overflow question to learn how to convert an integer to a Double: https://stackoverflow.com/questions/27467888/convert-int-to-double-in-swift I don't see any code in your calculate function where you do any calculations so I can't tell you where to put the code to convert to Double. Where do you perform the division?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’24
Reply to Why am I getting this error all over the project? Can anyone help solve it?
You have a link error, but your screenshot does not show the actual error. To find the actual error, press Cmd-9 in Xcode to open the report navigator. The report navigator will let you see all the build steps in your project. You may find the following article helpful: https://www.swiftdevjournal.com/why-wont-my-xcode-project-build/ When you find the actual error, reply in this thread and paste the text of the error message. Without the error message no one here can give you any more help. The usual causes of link errors are forgetting to include a framework and using the same name for a class or struct in your code that is in one of the frameworks your app links to.
Jan ’24
Reply to SwiftUi view responding to model changes
The reason the view doesn't respond to data changes when you switch to @State is that CheckItem is a class. The @State property wrapper works with structs, not classes. There are two ways to fix this. The first way is to make CheckItem a struct and remove @Published from any of the properties in CheckItem where you added them. By making CheckItem a struct, you can use @State and @Binding. The second way is to use @StateObject in the containing view and @ObservedObject in any other views where you want to use the CheckItem object. @StateObject is the class equivalent of @State, and @ObservedObject is the class equivalent of @Binding.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’24
Reply to Beginner error
You have two statements on one line without a semicolon separating them. You can't do that in Swift. var highscore = 0 highscore = 99 Place the statements on separate lines. var highscore = 0 highscore = 99 You could also simplify things by setting the value to 99 at the start. var highscore = 99 I don't know if that's enough to fix the build error. You didn't show much code. I recommend Hacking with Swift's 100 Days of SwiftUI free course to learn iOS development. They also have a forum where you can ask questions if you run into problems when going through the course. Their forum is more beginner friendly than this forum. https://www.hackingwithswift.com/100/swiftui
Topic: App & System Services SubTopic: Core OS Tags:
Jan ’24
Reply to XCode swift assistant editor
Im doing exactly what you said You did the first part of what I said, opening the assistant editor. That didn't work, as you get the header file for Apple's UIViewController class instead of the source code for your view controller. You didn't do the second part of what I said, opening a new editor view. Open a new editor view by clicking the rightmost button in the upper right corner of your screenshot, the button with a + sign in it. That will open a second view of the storyboard in Xcode. Above the storyboard in your screenshot is a jump bar that lets you jump to any file in your project. If you click the leftmost item in the jump bar, you will open a menu that will let you navigate through the files in your project. Go through the menus until you find your view controller file and choose that file, and you will be able to see the storyboard and source code side by side.
Jan ’24
Reply to XCode swift assistant editor
What is the course you are following? Above the source code editor on the right side are a set of buttons with small icons. Clicking the button with the stack of horizontal lines lets you open the assistant editor. Choose Assistant to open the assistant editor. If that doesn't do what you need, clicking the button with the + sign in the screenshot (the right button in the group of three at the top left of the screenshot) opens another editor view. That should let you see both the storyboard and the source code file at the same time. If that doesn't work, you are going to have provide more details on what you are trying to do.
Jan ’24
Reply to any example based on SpriteKit for getting started ?
There are two books that I would recommend to learn SpriteKit, one paid and one free. The paid one is Apple Game Frameworks and Technologies. https://pragprog.com/titles/tcswift/apple-game-frameworks-and-technologies/ The free one is 2D Apple Games by Tutorials. It covers SpriteKit. You may also have to deal with changes in Xcode since the book was published. You can download the book from Kodeco's deprecated book repository. https://github.com/kodecocodes/deprecated-books The site Check Sim Games has introductory SpriteKit articles. https://www.checksimgames.com/
Topic: Graphics & Games SubTopic: SpriteKit Tags:
Jan ’24
Reply to Xcode build/Developer Account
Choose Product > Archive in Xcode to archive your project. Open the Organizer by choosing Window > Organizer. Select your archived project from the list on the left side of the Organizer. Click the Distribute App button. Choose Copy App from the list of options. Click the Next button. Pick a location to save the app. Click the Export button. Optionally you can copy the exported app to your Applications folder. The following article has more details: https://www.swiftdevjournal.com/running-a-mac-app-outside-of-xcode/
Jan ’24