Education

RSS for tag

Teach students of all ages to code in Swift using a variety of resources in your curriculum.

Posts under Education tag

117 Posts

Post

Replies

Boosts

Views

Activity

1099-K How to report this?
If you grossed over $20,000 (or 200 sales) in sales from Apple you will receive a 1099-K.There are 2 problems with this:1) This will NOT reflect the 30% that Apple has withheld.2) A 1099-K will only be sent for those regions that meet the criteria for Apple issuing a 1099-K. Thus, this won't reflect all of your sales. Note: this is an assumption as I had more sales then this 1099-K reflects. In my case, I only received a 1099-K for US sales (I assume as it doesn't say). As a result, the difference from what the 1099k is reporting and what I actually received is only 12%, not 30%. That is, for example, the 1099-K says that I had$20,000 in sales, but what was actually deposited in my account was $17,600.How did you guys/gals fortunate/unfortunate enough to receive a 1099-K report this on your taxes?Did you, for example, have:a) 1099-K income of $20,000 with a business expense of 30% = $14,000b) Addional non-reported income of ($17,600-$14,000) = $3600Total: $17,600 (amount actually received from Apple sales)-OR-a) 1099-K income of $20,000 with a business expense of 12% = $17,600Thanks for the help with this!
8
1
13k
Aug ’22
problem with ForEach loop
when I'm using for each loop(using repeat command) instead of printing 5 items it is printing 10 times, it always doubles my command it is my code NavigationView {             ScrollView {                 ScrollView(.horizontal , showsIndicators: false){                     HStack(spacing: -10){                         ForEach(0..<5) { item in                             NavigationLink(destination: DetailView()) {                                 CardView()                             CardView()
2
0
1.2k
Aug ’22
Store a result in a constant
Hi, I am doing the first question of the last exercise on the following screenshot. However, I don't really understand the two questions. How is it possible to store a result in a constant, if the result itself is declared with 'let', making it a constant? I sure am not understanding correctly the question, understandable with the fact I just started learning code. Here's the block of code.     let total = pigsFlying + frogsBecomingPrinces + multipleLightningStrikes     return total } /*:  - callout(Exercise): Update the `impossibleBeliefsCount` function so that instead of printing the value, it returns it as an `Int`. `impossibleThingsPhrase` creates a phrase using string interpolation:  */ func impossibleThingsPhrase(numberOfImpossibleThings: Int, meal: String) -> String {     return "Why, I've believed as many as \(numberOfImpossibleThings) before \(meal)" } impossibleThingsPhrase(numberOfImpossibleThings: 712, meal: "chicken") /*:  - callout(Exercise): Update the `impossibleThingsPhrase` function so that, instead of using its two internal constants, it takes two arguments: `numberOfImpossibleThings` as an `Int` and `meal` as a `String`. Now you have two functions that take parameters and return values.  - callout(Exercise): Call `impossibleBeliefsCount` and store the result in a constant.\ Call `impossibleThingsPhrase`, passing in the result of `impossibleBeliefsCount` as one of the arguments.  */ func impossibleBeliefsCount(pigsFlying: Int, frogsBecomingPrinces: Int, multipleLightningStrikes: Int) {     let total = pigsFlying + frogsBecomingPrinces + multipleLightningStrikes     return total }
2
0
1.5k
Jul ’22
Where can I find a logical disjunction operator or function for Swift?
Is there a logical disjunction operator or function in Swift? Even better, is there a logical disjunction that works with optional variables instead of boolean variables that returns an object when true, and returns nil when false? A logical disjunction evaluates two boolean variables, and if at least one of them is true, then the return value is true. If neither variables is true, then the return value is false.
1
0
1.1k
Jun ’22
Expected declaration
Hello, I've been attempting to generate this code, but the last line returns an Expected declaration Error. class AboutMe { let firstName: String let lastName: String let age: Int init(firstName: String, lastName: String, age: Int){ self.firstName = firstName self.lastName = lastName self.age = age } var me: String { return "First Name: \(firstName), / Last Name: \(lastName), / Age: \(age)" } let myInfo = AboutMe(firstName: "NAME", lastName: "NAME", age: 10) print(myInfo) }
3
0
889
May ’22
For Swift Student Challenge, must all content be in English?
Hello all, I was wondering in the Swift Student Challenge requirements, it states: All content should be in English. What if my game is mainly in English (UI, main content,) but some foreign language (glyph to be specific) is used as part of app. The judge should be able to use the app without any fluency other than English. Will including some foreign language disqualify my entry? Thank you so much for answering my question. Nico
2
0
834
Apr ’22
ReadLine() - Very Common But Unsolvable Error "Unexpectedly found nil while unwrapping an Optional value"
Something wrong with Readline. I can't use readLine()!)! My code is really simple: var aYear = Int(readLine()!)! func isLeap(year: Int) {       var leap = "NO"       //IF divisible by 4 with no remainders.   if year % 4 == 0 {     leap = "YES"     //Is leap year, unless:   }   if year % 100 == 0 {     leap = "NO"     //Is not leap year, unless:   }   if year % 400 == 0 {     leap = "YES"     //Is leap year.   }   print(leap)   } //Don't change this isLeap(year: aYear) This error keeps coming up. I can't figure out how to fix this error: "__lldb_expr_122/readline .playground:1: Fatal error: Unexpectedly found nil while unwrapping an Optional value Playground execution failed: error: Execution was interrupted, reason: EXC_BREAKPOINT (code=1, subcode=0x18f494588). The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation." It is really strange because in online compiler this simple code works just fine. PLEASE HELP ME. I CAN'T FIND THE SOLUTION. It's kinda internal xcode error or what...
3
0
1.8k
Mar ’22
My view moves down and down with every opening of that view.
This is the content view which moves down on the screen as I open it from different view. when I click top left button to open menu. The menu When I click the Home option from menu whole view moves down on screen. The whole view gets moved down on screen each time I open it. //the content view import SwiftUI struct ContentView: View {     var body: some View {                       NavigationView{                               ScrollView{                      Text("Men")                          .font(.system(size: 30, weight:.bold))                      .padding(.trailing, 320.0)                  ScrollView(.horizontal){                      HStack{                          NavigationLink(destination:mentshirt()){                          custom(content:Image("mentshirt"),over:"T-shirt",col: .black)                          }                          NavigationLink(destination:menjeans()){                          custom(content:Image("menjeans"),over:"Jeans",col: .black)                          }                          NavigationLink(destination:menjacket()){                          custom(content:Image("menjacket"),over: "Jacket",col: .black)                          }                      }                  }                      Text("Women")                          .font(.system(size: 30,weight: .bold))                          .padding(.trailing,280.0)                  ScrollView(.horizontal){                      HStack{                          NavigationLink(destination:womentshirt()){                          custom(content:Image("womentshirt"),over:"T-shirt",col: .black)                          }                          NavigationLink(destination:womenjeans()){                          custom(content:Image("womenjeans"),over:"Jeans",col: .black)                          }                          NavigationLink(destination:womenjacket()){                          custom(content:Image("womenjacket"),over:"Jacket",col: .black)                          }                      }                  }                      Text("Kids")                          .font(.system(size: 30,weight: .bold))                          .padding(.trailing,320.0)                  ScrollView(.horizontal){                      HStack{                          NavigationLink(destination:kidtshirt()){                              custom(content:Image("kidtshirt"),over:"T-shirt",col:.black)                      }                          NavigationLink(destination:kidjeans()){                          custom(content:Image("kidjeans"),over:"Jeans",col: .black)                          }                              NavigationLink(destination:kidjacket()){                          custom(content:Image("kidjacket"),over:"Jacket",col:.black)                              }                      }                  }                  }                  .navigationBarBackButtonHidden(true)                  .navigationBarItems(leading:                                          NavigationLink(                                          destination: clothlist()){                                                  navcustom(content:                                                             Image(systemName: "line.horizontal.3"),col: .white)                          },                      trailing:                              HStack{                      Image("logo")                          .resizable()                          .clipShape(Circle())                          .shadow(color:.white,radius: 10)                          .frame(width: 30, height: 30, alignment: .center)                              Spacer(minLength: 80)                          NavigationLink(destination: cart()){                              navcustom(content:                                         Image(systemName: "cart"),col: .white)                          }                          Spacer(minLength: 15)                              NavigationLink(destination: login()){                                  navcustom(content:Image(systemName: "person.crop.circle.fill"), col: .white)                              }                          }                  )              }.navigationBarBackButtonHidden(true)             .ignoresSafeArea()         } } struct ContentView_Previews: PreviewProvider {     static var previews: some View {         Group {               ContentView()                 .environment(\.colorScheme, .dark)         }     } } func custom(content:Image,over:String,col:Color) -> some View {     content         .resizable()         .overlay(Text(over).font(.system(size: 20,weight: .bold)).foregroundColor(col),alignment: .bottomLeading)         .frame(width: 400, height: 500, alignment: .center)         .padding(5)                        } func navcustom(content:Image,col:Color)-> some View {     content         .resizable()         .frame(width: 30, height: 30, alignment: .center)         .foregroundColor(col) } //the menu view from which I open content view import SwiftUI struct clothlist: View {     var body: some View {         List         {             NavigationLink(destination:ContentView())             {             Text(Image(systemName: "house"))+Text(" Home")             }             Text(Image(systemName: "person"))+Text(" Men")             NavigationLink(destination:menjeans())             {             Text("Jeans")             }             NavigationLink(destination:menjacket())             {             Text("Jacket")             }             NavigationLink(destination:mentshirt())             {             Text("Tshirt")             }             Text(Image(systemName: "person"))+Text(" Women")             NavigationLink(destination:womenjeans())             {             Text("Jeans")             }             NavigationLink(destination:womenjacket())             {             Text("Jacket")             }             NavigationLink(destination:womentshirt())             {             Text("Tshirt")             }             Group{             Text(Image(systemName: "person"))+Text(" Kids")             NavigationLink(destination:kidjeans())             {             Text("Jeans")             }             NavigationLink(destination:kidjacket())             {             Text("Jacket")             }             NavigationLink(destination:kidtshirt())             {             Text("Tshirt")             }             }         }         .navigationBarBackButtonHidden(true)     } } struct clothlist_Previews: PreviewProvider {     static var previews: some View {         clothlist()     } } how to stop the view from moving down on screen on every open?
0
0
1.3k
Mar ’22
Swift Playgrounds
easy to create apps > `adding_funtions ``` > `What other methods and creative possibilities can work with swift playgrounds? name some! ` > samples are welcome
Replies
1
Boosts
0
Views
1.3k
Activity
Sep ’22
I can't use update with scrum. How can I fix this?
Urgent!
Replies
3
Boosts
2
Views
2.3k
Activity
Aug ’22
1099-K How to report this?
If you grossed over $20,000 (or 200 sales) in sales from Apple you will receive a 1099-K.There are 2 problems with this:1) This will NOT reflect the 30% that Apple has withheld.2) A 1099-K will only be sent for those regions that meet the criteria for Apple issuing a 1099-K. Thus, this won't reflect all of your sales. Note: this is an assumption as I had more sales then this 1099-K reflects. In my case, I only received a 1099-K for US sales (I assume as it doesn't say). As a result, the difference from what the 1099k is reporting and what I actually received is only 12%, not 30%. That is, for example, the 1099-K says that I had$20,000 in sales, but what was actually deposited in my account was $17,600.How did you guys/gals fortunate/unfortunate enough to receive a 1099-K report this on your taxes?Did you, for example, have:a) 1099-K income of $20,000 with a business expense of 30% = $14,000b) Addional non-reported income of ($17,600-$14,000) = $3600Total: $17,600 (amount actually received from Apple sales)-OR-a) 1099-K income of $20,000 with a business expense of 12% = $17,600Thanks for the help with this!
Replies
8
Boosts
1
Views
13k
Activity
Aug ’22
Learning Swift from Swift Playgrounds
I am new to learning Swift, so I just downloaded Swift Playgrounds, but I can see many Playgrounds to choose from, so from where do I start?
Replies
2
Boosts
0
Views
1.1k
Activity
Aug ’22
problem with ForEach loop
when I'm using for each loop(using repeat command) instead of printing 5 items it is printing 10 times, it always doubles my command it is my code NavigationView {             ScrollView {                 ScrollView(.horizontal , showsIndicators: false){                     HStack(spacing: -10){                         ForEach(0..<5) { item in                             NavigationLink(destination: DetailView()) {                                 CardView()                             CardView()
Replies
2
Boosts
0
Views
1.2k
Activity
Aug ’22
Additional playgrounds in Swift Playground
I am trying to access Lego Mindstorm EV3 playground. In tutorials online I see that people can search for additional playgrounds to add to their Swift Playgrounds, but in my app, my only option is to enter a subscription URL and I'm unsure how to obtain this. Can anyone help?
Replies
1
Boosts
1
Views
1.3k
Activity
Aug ’22
Develop in Swift Explorations lessons
I am working on an iOS iPad and want to download the student materials from the book, Develop in Swift Explorations. Since I cannot download Xcode without MaciOS, is there any way to convert these materials to a file that can be accessed in Swift Playgrounds and opened on my iPad?
Replies
0
Boosts
0
Views
1.3k
Activity
Aug ’22
Store a result in a constant
Hi, I am doing the first question of the last exercise on the following screenshot. However, I don't really understand the two questions. How is it possible to store a result in a constant, if the result itself is declared with 'let', making it a constant? I sure am not understanding correctly the question, understandable with the fact I just started learning code. Here's the block of code.     let total = pigsFlying + frogsBecomingPrinces + multipleLightningStrikes     return total } /*:  - callout(Exercise): Update the `impossibleBeliefsCount` function so that instead of printing the value, it returns it as an `Int`. `impossibleThingsPhrase` creates a phrase using string interpolation:  */ func impossibleThingsPhrase(numberOfImpossibleThings: Int, meal: String) -> String {     return "Why, I've believed as many as \(numberOfImpossibleThings) before \(meal)" } impossibleThingsPhrase(numberOfImpossibleThings: 712, meal: "chicken") /*:  - callout(Exercise): Update the `impossibleThingsPhrase` function so that, instead of using its two internal constants, it takes two arguments: `numberOfImpossibleThings` as an `Int` and `meal` as a `String`. Now you have two functions that take parameters and return values.  - callout(Exercise): Call `impossibleBeliefsCount` and store the result in a constant.\ Call `impossibleThingsPhrase`, passing in the result of `impossibleBeliefsCount` as one of the arguments.  */ func impossibleBeliefsCount(pigsFlying: Int, frogsBecomingPrinces: Int, multipleLightningStrikes: Int) {     let total = pigsFlying + frogsBecomingPrinces + multipleLightningStrikes     return total }
Replies
2
Boosts
0
Views
1.5k
Activity
Jul ’22
Getting "Develop in Swift" curriculum books in China
Apple has a "Develop in Swift" curriculum with three books available at https://developer.apple.com/learn/curriculum/. However, they link to Apple Books, which isn't available in China. Is there any possible way to download an English copy of it without going through Books? Thanks!
Replies
2
Boosts
0
Views
691
Activity
Jul ’22
key value coding sample
I'm looking for the Swift tutorial that had always been used since I started learning Swift for the first time about 5 years ago. I can't remember the name. It was an app that reviewed restaurants, as I remember. I need a sample of key-value-coding. I recall that tutorial used key-value-coding.
Replies
1
Boosts
0
Views
1k
Activity
Jun ’22
Where can I find a logical disjunction operator or function for Swift?
Is there a logical disjunction operator or function in Swift? Even better, is there a logical disjunction that works with optional variables instead of boolean variables that returns an object when true, and returns nil when false? A logical disjunction evaluates two boolean variables, and if at least one of them is true, then the return value is true. If neither variables is true, then the return value is false.
Replies
1
Boosts
0
Views
1.1k
Activity
Jun ’22
How to learn "real" Swift
I am 14 years old and would like to participate in the Swift Student Challenge @ WWDC23. I have no experience programming in Swift or any other programming language. What do you suggest to learn Swift?
Replies
5
Boosts
0
Views
1.6k
Activity
Jun ’22
Accessing Buttons Through Different View Controllers
Hi, does anyone know how to access buttons through a different view controller in Xcode? For example, in firstViewController I placed a button that is disabled, but once the user presses the button in the secondViewController, the button in firstViewController becomes enabled.
Replies
4
Boosts
0
Views
1.6k
Activity
May ’22
Expected declaration
Hello, I've been attempting to generate this code, but the last line returns an Expected declaration Error. class AboutMe { let firstName: String let lastName: String let age: Int init(firstName: String, lastName: String, age: Int){ self.firstName = firstName self.lastName = lastName self.age = age } var me: String { return "First Name: \(firstName), / Last Name: \(lastName), / Age: \(age)" } let myInfo = AboutMe(firstName: "NAME", lastName: "NAME", age: 10) print(myInfo) }
Replies
3
Boosts
0
Views
889
Activity
May ’22
Python
When I go to my terminal and type in "python" or "python --version" I get back "command not found: python" I have the newest version downloaded but not even version 2 isn't showing up. What do I do? I even just factory reset my mac. I'm running the M1 mini
Replies
4
Boosts
0
Views
1.8k
Activity
May ’22
For Swift Student Challenge, must all content be in English?
Hello all, I was wondering in the Swift Student Challenge requirements, it states: All content should be in English. What if my game is mainly in English (UI, main content,) but some foreign language (glyph to be specific) is used as part of app. The judge should be able to use the app without any fluency other than English. Will including some foreign language disqualify my entry? Thank you so much for answering my question. Nico
Replies
2
Boosts
0
Views
834
Activity
Apr ’22
Event admission and accommodation
In addition to this year's 2022 award mentioned on the website, does Apple pay for student admission and accommodation?
Replies
0
Boosts
0
Views
561
Activity
Apr ’22
ReadLine() - Very Common But Unsolvable Error "Unexpectedly found nil while unwrapping an Optional value"
Something wrong with Readline. I can't use readLine()!)! My code is really simple: var aYear = Int(readLine()!)! func isLeap(year: Int) {       var leap = "NO"       //IF divisible by 4 with no remainders.   if year % 4 == 0 {     leap = "YES"     //Is leap year, unless:   }   if year % 100 == 0 {     leap = "NO"     //Is not leap year, unless:   }   if year % 400 == 0 {     leap = "YES"     //Is leap year.   }   print(leap)   } //Don't change this isLeap(year: aYear) This error keeps coming up. I can't figure out how to fix this error: "__lldb_expr_122/readline .playground:1: Fatal error: Unexpectedly found nil while unwrapping an Optional value Playground execution failed: error: Execution was interrupted, reason: EXC_BREAKPOINT (code=1, subcode=0x18f494588). The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation." It is really strange because in online compiler this simple code works just fine. PLEASE HELP ME. I CAN'T FIND THE SOLUTION. It's kinda internal xcode error or what...
Replies
3
Boosts
0
Views
1.8k
Activity
Mar ’22
My view moves down and down with every opening of that view.
This is the content view which moves down on the screen as I open it from different view. when I click top left button to open menu. The menu When I click the Home option from menu whole view moves down on screen. The whole view gets moved down on screen each time I open it. //the content view import SwiftUI struct ContentView: View {     var body: some View {                       NavigationView{                               ScrollView{                      Text("Men")                          .font(.system(size: 30, weight:.bold))                      .padding(.trailing, 320.0)                  ScrollView(.horizontal){                      HStack{                          NavigationLink(destination:mentshirt()){                          custom(content:Image("mentshirt"),over:"T-shirt",col: .black)                          }                          NavigationLink(destination:menjeans()){                          custom(content:Image("menjeans"),over:"Jeans",col: .black)                          }                          NavigationLink(destination:menjacket()){                          custom(content:Image("menjacket"),over: "Jacket",col: .black)                          }                      }                  }                      Text("Women")                          .font(.system(size: 30,weight: .bold))                          .padding(.trailing,280.0)                  ScrollView(.horizontal){                      HStack{                          NavigationLink(destination:womentshirt()){                          custom(content:Image("womentshirt"),over:"T-shirt",col: .black)                          }                          NavigationLink(destination:womenjeans()){                          custom(content:Image("womenjeans"),over:"Jeans",col: .black)                          }                          NavigationLink(destination:womenjacket()){                          custom(content:Image("womenjacket"),over:"Jacket",col: .black)                          }                      }                  }                      Text("Kids")                          .font(.system(size: 30,weight: .bold))                          .padding(.trailing,320.0)                  ScrollView(.horizontal){                      HStack{                          NavigationLink(destination:kidtshirt()){                              custom(content:Image("kidtshirt"),over:"T-shirt",col:.black)                      }                          NavigationLink(destination:kidjeans()){                          custom(content:Image("kidjeans"),over:"Jeans",col: .black)                          }                              NavigationLink(destination:kidjacket()){                          custom(content:Image("kidjacket"),over:"Jacket",col:.black)                              }                      }                  }                  }                  .navigationBarBackButtonHidden(true)                  .navigationBarItems(leading:                                          NavigationLink(                                          destination: clothlist()){                                                  navcustom(content:                                                             Image(systemName: "line.horizontal.3"),col: .white)                          },                      trailing:                              HStack{                      Image("logo")                          .resizable()                          .clipShape(Circle())                          .shadow(color:.white,radius: 10)                          .frame(width: 30, height: 30, alignment: .center)                              Spacer(minLength: 80)                          NavigationLink(destination: cart()){                              navcustom(content:                                         Image(systemName: "cart"),col: .white)                          }                          Spacer(minLength: 15)                              NavigationLink(destination: login()){                                  navcustom(content:Image(systemName: "person.crop.circle.fill"), col: .white)                              }                          }                  )              }.navigationBarBackButtonHidden(true)             .ignoresSafeArea()         } } struct ContentView_Previews: PreviewProvider {     static var previews: some View {         Group {               ContentView()                 .environment(\.colorScheme, .dark)         }     } } func custom(content:Image,over:String,col:Color) -> some View {     content         .resizable()         .overlay(Text(over).font(.system(size: 20,weight: .bold)).foregroundColor(col),alignment: .bottomLeading)         .frame(width: 400, height: 500, alignment: .center)         .padding(5)                        } func navcustom(content:Image,col:Color)-> some View {     content         .resizable()         .frame(width: 30, height: 30, alignment: .center)         .foregroundColor(col) } //the menu view from which I open content view import SwiftUI struct clothlist: View {     var body: some View {         List         {             NavigationLink(destination:ContentView())             {             Text(Image(systemName: "house"))+Text(" Home")             }             Text(Image(systemName: "person"))+Text(" Men")             NavigationLink(destination:menjeans())             {             Text("Jeans")             }             NavigationLink(destination:menjacket())             {             Text("Jacket")             }             NavigationLink(destination:mentshirt())             {             Text("Tshirt")             }             Text(Image(systemName: "person"))+Text(" Women")             NavigationLink(destination:womenjeans())             {             Text("Jeans")             }             NavigationLink(destination:womenjacket())             {             Text("Jacket")             }             NavigationLink(destination:womentshirt())             {             Text("Tshirt")             }             Group{             Text(Image(systemName: "person"))+Text(" Kids")             NavigationLink(destination:kidjeans())             {             Text("Jeans")             }             NavigationLink(destination:kidjacket())             {             Text("Jacket")             }             NavigationLink(destination:kidtshirt())             {             Text("Tshirt")             }             }         }         .navigationBarBackButtonHidden(true)     } } struct clothlist_Previews: PreviewProvider {     static var previews: some View {         clothlist()     } } how to stop the view from moving down on screen on every open?
Replies
0
Boosts
0
Views
1.3k
Activity
Mar ’22
Resource recommendations for beginners?
Hi friends. I'm new around here and just migrated from Windows to macOS. I started working on iOS development with Swift. So if you have any study resource suggestions for beginners, can you share them? I am open to all resources such as documents, websites, videos.
Replies
0
Boosts
0
Views
489
Activity
Mar ’22