CS193p | CS193p 2017 & 2021 - Developing Apps | iOS library
kandi X-RAY | CS193p Summary
kandi X-RAY | CS193p Summary
Notes & code for CS193p - Developing Apps for iOS.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of CS193p
CS193p Key Features
CS193p Examples and Code Snippets
Community Discussions
Trending Discussions on CS193p
QUESTION
I am learning Stanford CS193p, and everything went so well till switching LazyVGrid with HStack.
I checked my code with the one professor made, they are the same. But the confusing part of my code is that, when my emojiCount = 4, preview worked well, I can use LazyVGrid, however when I changed emojiCount value more than 4, like 5 or 24, it would crash right away.
The crash info is this:
And here is my code:
...ANSWER
Answered 2021-May-29 at 18:19Run the code in the simulator and you will see the error
Fatal error: each layout item may only occur once
This leads to the emojis. You have a lot of them but only 4 different types.
In a loop where the items are referenced by \.self
you are responsible for making sure that the items are unique.
QUESTION
I am following Stanfords' CS193p Developing Apps for iOS online course. I am using Xcode 11.5. I didn't update because that's the version the course instructor (Paul Heagarty) is using. I have to have (for now) this Xcode version. So I didn't yet updated my macOS to Big Sur, because I am afraid, that I will not be able to use Xcode 11.5 on macOS Big Sur.
Is it possible to use Xcode 11.5 on the latest macOS Big Sur? Or will Xcode 11.5 it just stop working if I will update to Big Sur? I have an Intel-based Mac. (not M1 Apple Silicon)
And also - can I have both the Xcode 11.5 & the latest Xcode 12.x version at the same time?
...ANSWER
Answered 2021-Feb-04 at 22:53Xcode 11.5 is not officially supported on Big Sur so 11.5 is not guaranteed to run on Big Sur, but you should be able to use 11.5 on Big Sur.
You can have multiple versions of Xcode installed. If you install Xcode from the App Store, make sure you change the name of your Xcode 11.5 install from Xcode to something else, such as Xcode11.5. If you don't change the name of your existing Xcode installation, the new version of Xcode will overwrite the existing version.
Xcode 12.4 runs on Catalina so you can have both Xcode 11.5 and 12.4 installed without having to install Big Sur.
QUESTION
I'm teaching myself SwiftUI by taking the 2020 version of Stanford's CS193p posted on YouTube.
I'd like to have a ZStack
with a check box in the bottom right. This code puts the check mark
right in the middle of the View.
ANSWER
Answered 2020-Nov-24 at 00:44Try applying
QUESTION
I am following Stanfords' CS193p Developing Apps for iOS online course. I am using Xcode 11.5. (I didn't update because that's the version the course instructor (Paul Heagarty) is using.)
I'm trying to do the Assignment 3 (Set Game). Currently (to avoid duplicating code) I am trying to replace this fragment:
...ANSWER
Answered 2020-Dec-04 at 10:05stroke
is defined on Shape
, not View
and you are returning Shape
s, not just View
s. You need to change the return type of shape
to some Shape
.
Sadly @ViewBuilder
needs the return type to be some View
, not some Shape
, so you need to remove the @ViewBuilder
attribute and make sure your function returns the same Shape
from each branch. To achieve this, you can implement a type-erased Shape
, called AnyShape
similar to AnyView
for View
and return the type erased version of each Shape
.
QUESTION
I am following Stanfords' CS193p Developing Apps for iOS online course. I am using Xcode 11.5. (I didn't update because that's the version the course instructor (Paul Heagarty) is using.)
I'm trying to do the Assignment 3 (Set Game). I know my code is probably poorly written in many places, but I am going to refine it later, right now I am just trying to make it work with no errors. The error I currently can not fix is this:
...ANSWER
Answered 2020-Nov-21 at 03:30This is going to sound a bit existential, but the compiler is complaining because you are trying to set shading
to a vault that does not exist yet. When you first set the values of your variables in the View, they do not actually exist. You are telling the compiler what they are going to be, but the compiler insists that the thing that you have said the variable will be actually exists.
There are ways around this, such as George E. suggesting a lazy var. I don't want to go down that route as that is beyond a beginner. For your purposes just know, when you define a variable, it must be give an actual value. The compiler won't complain about var x = 1
because it knows what 1 is, and it already exists.
Your exact error says you can't use the instance card
because it has not been initialized at the time you are trying to use it. In other words, it has no value when you are trying to assign it, as card.shading
to shading
.
Now, that being said, why do you need shading at all? Isn't the shading you want always going to be card.shading
? Rather than make a separate variable, just use what you have. Learn to love dot notation and keep it simple.
The last thing to consider, outside of your original question, is that you have a view without any State variables. Your compiler will complain at runtime if you try to change a variable that is not marked @State. What you have created is a fixed view, not one that can change or update.
QUESTION
So I tried to learn SwiftUI from Stanford CS193p. This works great, however, I can't get my head around why this is not working. I have the same exact view as the instructor has:
...ANSWER
Answered 2020-Jun-10 at 10:57The implementation of the equality operator in your Card struct only compares ids. The CardView is not updated because SwiftUI deduces the card hasn't changed.
Note that you may want to check for the other properties of card as well (CardContent would need to conform to Equatable).
QUESTION
I am following Stanfords' CS193p iOS Development online course. I am with Xcode 11.3 and Swift 5.1.2.
ProblemBy the end of lecture 5. ViewBuilder + Shape + ViewModifier, an error occurred to me, which is the Swift compiler reported 'Generic parameter 'S' could not be inferred'. Snapshot: IDE complains about it
Code Snippets Code inEmojiMemoryGameView.swift
...ANSWER
Answered 2020-Jul-29 at 05:23In your struct CardView: View
, you have
QUESTION
I'm trying to learn SwiftUI from a series of lectures from Stanford(https://cs193p.sites.stanford.edu/) and am having some issues with animations. I'm creating the game Set which is a matching game where you select three cards and if they match then they are replaced with new cards etc.
Currently to show that a card has been selected the border color turns orange. The issue that im having is that when three cards are selected and match I would like the border color to flash green if matched or red if not matched. This is the code that that draws the grid of cards
...ANSWER
Answered 2020-Jul-16 at 20:04I assume the problem is with changing the color and changing it back in some amount of time.
If that is the case, use DispatchQueue.asyncAfter(deadline: DispatchTime) {}
.
usage:
QUESTION
I'm currently following a series of lectures from Stanford to learn Swift (Code is from lectures 1-4 plus the homework I'm trying to complete) and am having an issue with setting an instance var(non-static) from a static function. I have gotten this to work but I would like it to be able to have different instances of the game have different themes
...ANSWER
Answered 2020-Jun-30 at 09:12Just let your ThemesArray be a static variable like it is. However, you won't need to declare selectedTheme
as static
. As you say, it is an instance variable.
Declare selectedTheme
as following:
QUESTION
I'm following Stanford CS193P 2020 youtube sessions. I got stuck with the behavior of my custom diamond shape. My custom shape frame (no matter which modifier I place frame, etc) is always bigger than the space where it is drawn and the built in shapes always take the given space. The result of this is that all my custom shapes have different sizes according to the space its frame takes. I don't know how to solve this problem. The concrete question would be, how do I obtain the same frame in my custom shape as I obtain in rectangle or capsule?. I'll paste you an image of the drawing and the code below. Thanks for your help.
Custom shape code.
...ANSWER
Answered 2020-Jun-13 at 21:56Solved I was drawing wrongly my diamond shape. I needed to draw in the whole frame not, just the minimun dimension. Then the diamond would occupy the whole frame.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install CS193p
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page