Post not yet marked as solved
For the Swift Student Challenge it says that it must run on MacOS or iPadOS as a Swift Playgrounds App. I have been working on an iOS app in XCode as a Swift Playgrounds App. I assumed MacOS just meant we were working on the app on Mac XCode which in hindsight could be a massive misinterpretation.
I know we have to use Swift Playgrounds App. Do we have to create a Mac app or an it be an iPhone app that runs on the XCode simulator on a Mac? And if it is an iPhone app that runs on a simulator, is there a specific iPhone simulation being used? The description specifies that iPadOS must be optimized for all models- does that imply that an iOS does not have to?
Post not yet marked as solved
I want to make it like this
How to disable the button that open the side bar, I only need the content and the detail view. I don't need the sidebar view.
Below is my code
import SwiftUI
@available(iOS 16.0, *)
struct Screen: View {
@ObservedObject var userData = UserData()
@State private var isIntroShown = true
@State var Itema: Bool = false
@State private var showFoodDetail = false
@State var rb: Bool = false
@State var Setting: Bool = false
@State var Recipe: Bool = false
@Environment(\.defaultMinListRowHeight) var minRowHeight
@Environment(\.colorScheme) var colorScheme
@State private var searchText = ""
private let adaptiveColumns = [
GridItem(.adaptive(minimum: 170))
]
var columns = Array(repeating: GridItem(.flexible(), spacing: 10), count: 2)
var filteredRooms: [Room] {
if searchText.isEmpty {
return userData.rooms
} else {
return userData.rooms.filter { room in
let foodNames = room.food.map { $0.name.lowercased() }
return room.name.lowercased().contains(searchText.lowercased()) ||
foodNames.contains { $0.contains(searchText.lowercased()) }
}
}
}
@State private var columnVisibility = NavigationSplitViewVisibility.doubleColumn
var body: some View {
NavigationSplitView (columnVisibility: $columnVisibility){
} content: {
ScrollView{
GridView()
.padding(.horizontal)
.padding(.bottom, 20)
}.toolbar {
ToolbarItem(placement: .bottomBar){
Button(action:{self.Itema = true}) {
HStack {
Image(systemName: "plus.circle.fill").resizable().frame(width: 20, height: 20).foregroundColor(.white)
Text("New Item").foregroundColor(.white).bold()
}
}
.sheet(isPresented: self.$Itema){
NewItem(userData: self.userData)
}
}
ToolbarItem(placement: .bottomBar){
Button(action:{self.rb = true}) {
HStack {
Text("New Room").foregroundColor(.white)
}
}
.sheet(isPresented: self.$rb){
NewRoom(userData: self.userData)
}
}
ToolbarItem(placement: .navigationBarTrailing){
Button(action:{self.Setting = true}) {
HStack {
Image(systemName: "gear").foregroundColor(.white)
}
}
.sheet(isPresented: self.$Setting){
NavigationView {
NewItem( userData: userData)
.navigationBarItems(trailing:Button(action: {
self.Setting = false
}){
Text("Done")
}
)
}
}
}
}
.background(Color(red: 203/255, green: 237/255, blue: 207/255))
} detail: {
ZStack {
Text("")
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color(red: 220/255, green: 247/255, blue: 234/255))
}
.searchable(text: $searchText)
}
}
Post not yet marked as solved
I'm scared I accidentally submitted the wrong file and was just wondering if I withdrew my submission would I be able to send it back in? Also there was a question asking about what stem organization I'm in, it said it was optional but it forced me to choose one so I chose other and typed "None of them", that should be okay right?
Post not yet marked as solved
Hi, I am trying to save and retrieve an object in coredata with the following attributes: id, classification de tipo String, values de tipo [(Double, Double)], but I don't know how to save values:[(Double, Double)].
Thanks, greetings.
As far as I know, the winning result confirmation webpage disappears after a few years.
I want to use the fact that I won when I get a job in a few years, but how can I prove it?
Post not yet marked as solved
I won the challenge.
Will supervisors be contacted further after I win? (Requirements such as student identification)
If so, I would like to consult with the supervisor.
Post not yet marked as solved
I just won the Challenge this year, and I was wondering if it would be okay to share my submission through TestFlight / App Store or commercialize it.
Thanks!
Post not yet marked as solved
Hi coder friends! Congratulations to everyone who submitted a project for this year's challenge! It was my first year applying, and while I did not win, I am really proud of the project I created. It's called Codele, it's like Wordle but instead it's daily coding questions!
I would love to connect with another applicants whose projects were not selected in order to amplify, share, and celebrate their work. I know how hard I worked on my submission and I imagine that many of us who did not win did too.
If you're interested in having your project shared and celebrated, please shoot me a DM on LinkedIn @Izzy Lapidus about your project and I will send you more details! Looking forward to connecting and hearing about your project :)
-Izzy :)
Hi!
I won the Swift Student Challenge this year, and I wonder when the awards arrive (so hyped for that!) as I see some unboxing videos and posts on the Internet.
Any clues ?
Thanks!
Post not yet marked as solved
Picker("Priority", selection: $selectedPriority)
( Cannot find '$selectedPriority' in scope)
Post not yet marked as solved
import SwiftUI
struct Splashscreenview: View {
@State private var isActive = false
@State private var size = 0.8
@State private var opacity = 0.5
var body: some View {
if isActive{
ContentView()
} else{
VStack {
VStack{
Image(systemName: "hare.fill")
.font(.system(size: 100))
.foregroundColor(.blue)
Text("Smartt Bank")
.font(Font.custom("Baskerville-Bold", size: 30))
.foregroundColor(.black.opacity(0.80))
}
.scaleEffect(size)
.opacity(opacity)
.onAppear{
withAnimation(.easeIn(duration: 1.2)){
self.size = 0.9
self.opacity = 1.0
}
}
}
.onAppear{
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
self.isActive = true
}
}
}
}
}
struct Splashscreenview_Previews: PreviewProvider {
static var previews: some View {
Splashscreenview()
}
}
Post not yet marked as solved
I am relatively new to coding and put together this countdown timer based on code available in various public forums. This countdown timer for my iPhone puts a timer on my screen, allows me to select the time counted down in minutes and seconds, then to start the timer and, if so desired, reset it.While such timers are readily available, I wanted to try and build one myself and learn swift in the process. The program builds and runs fine. However the latter section is intended to play a chime when the countdown timer reaches the 1/2 way point and then when it finishes. This is not working and I'm at a loss to get it to do so. I would appreciate it if someone would modify my code to make this work. Also, I don't know how to compile the program so that I can move it off my MacBook and onto my iPad and would appreciate guidance on that. The code follows: Thank you
//
// Content-ViewModel.swift
// Countdown Timer
//
//
//
import Foundation
import AVFoundation
extension ContentView { //contains the initial user interface
final class ViewModel: ObservableObject {
@Published var isActive = false
@Published var showingAlert = false
@Published var time: String = "1:00"
@Published var minutes: Float = 1.0 {
didSet {
self.time = "\(Int(minutes)):00"
}
}
private var initialTime = 0 // sets the var initialTime to 0
private var endDate = Date() // sets endDate to the current date
// this next func starts timer in minutes
func start(minutes: Float) { // this starts timer in minutes
self.initialTime = Int(minutes)
self.endDate = Date()
self.isActive = true // true means the timer is active
self.endDate = Calendar.current.date(byAdding: .minute, value: Int(minutes), to: endDate)!
}
// this next func updates the var minutes to original time
func reset() {
self.minutes = Float(initialTime)
self.isActive = false
self.time = "\(Int(minutes)):00"
}
// this next func calculates the elapsed time
func updateCountDown() {
guard isActive else { return }
let now = Date()
let diff = endDate.timeIntervalSince1970 - now.timeIntervalSince1970
if diff <= 0 { // means timer is at zero
self.isActive = false
self.time = "0:00"
self.showingAlert = true
return
// coud add code here to signify time is up
}
// This next code allows us to grab minutes and seconds from the calendar
let date = Date(timeIntervalSince1970: diff)
let calendar = Calendar.current
let minutes = calendar.component(.minute, from: date)
let seconds = calendar.component(.second, from: date)
self.minutes = Float(minutes)
self.time = String(format: "%d:%02d", minutes, seconds) // this creates the 2 digit display of minutes and seconds as a string
let halftime = minutes/2 // This shoud create a float variable equal to 1/2 run time
let chimesSoundEffect = "Chimes-sound-effect.mp3"
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
var player: AVAudioPlayer?
func playSound() {
guard let url = Bundle.main.url(forResource: "sound", withExtension: "mp3") else { return }
do {
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default)
try AVAudioSession.sharedInstance().setActive(true)
player = try AVAudioPlayer(contentsOf: url, fileTypeHint: AVFileType.mp3.rawValue)
guard let player = player else { return }
player.play()
}
catch let error {
print(error.localizedDescription)
}
let timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { timer in
/* why doesn't the sound play when the halftime reached minutes/2 or when time reaches 0 */
if minutes == halftime {
playSound()
if minutes == 0 {
timer.invalidate()
playSound()
}
}
}
}
}
}
}
Post not yet marked as solved
I keep trying to insert imageLiteral
since my class uses an older version of Xcode the function ain't the same
so I was told to use #imageLiteral(
then the option of picking an image from assets work
I picked the image but as soon as I do
get this error msg
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
what going on and how can I fix it ?
Post not yet marked as solved
My while loop continues execution after reaching gemsCollected = 3 if I use OR logical operator (||) and stops execution if I use AND logical operator (&&).
IMHO it should be the other way around, right?
var gemsCollected = 0
var switchesToggled = 0
while gemsCollected < 3 || switchesToggled < 4 {
moveForward()
if gemsCollected < 3 && isOnGem {
collectGem()
gemsCollected = gemsCollected + 1
} else if switchesToggled < 4 && isOnClosedSwitch {
toggleSwitch()
switchesToggled = switchesToggled + 1
} else if isBlocked && !isBlockedRight {
turnRight()
} else if isBlocked && !isBlockedLeft {
turnLeft()
}
}
Hello, i am working on my project for the Swift Student Challenge and it came to my attention that the project must be built using Swift Playgrounds. I have run into an issue where I want to add multiple views to my project but it seems i am unable. How am i supposed to do this?
On the swift student challenge page it says "Your app playground must be built with and run on Swift Playgrounds 4.2.1 or later (requires iPadOS 16 or macOS 13) or Xcode 14 on macOS 13." Could I build it with Xcode in a swift.pm file but ask for it to be viewed on iPhone?
Post not yet marked as solved
I just read the announcement of the next Swift Student Challenge and one thing was not super clear to me. It says that applications will start in February and they'll run for 3 weeks. Is the application process just going to verify if I'm eligible to participate or will I already have to have a playground App ready submit with my application?
I was going through the eligibility criteria to participate and it said we had to be part of the Apple Developer Program. Does that mean that we have to pay in order to participate?
The Swift challenge page mentions playgrounds in both Swift Playgrounds and Xcode. Do I have to use an app playground or can I instead use an app project in Xcode? I feel more comfortable working with an Xcode project. Is it possible to convert my project to a .swiftpm file later?
Thanks
Post not yet marked as solved
could you please recommend sever choices of local database I can use or the ways to store data in app playground, like can I use realm or sqlite?