What‘s new in Swift

RSS for tag

Discuss the WWDC21 session What‘s new in Swift.

View Session

Posts under wwdc21-10192 tag

25 Posts
Sort by:
Post not yet marked as solved
0 Replies
152 Views
hi everyone, is there anyone meet same problem with me? if yes please tell me the solution plz is urgent. my situation is project created with webview by swift native Xcode and when i loaded success website that embedded scorm.js it will stuck in the middle of playing full content scorm , this issue happen in IOS 15.4 previous version don have this issue...
Posted
by
Post marked as solved
5 Replies
349 Views
I have parsed a json file with the following structure into a table view succesfully. import Foundation struct ActionResult: Codable {     let data3: [Datum] } struct Datum: Codable {     let actionGoal, actionGoalDescription, actionGoalImage: String     let actions: [Action] } struct Action: Codable {     let actionTitle: String     let actionID: Int     let select, completed, favorite: Bool     let actionType, actionDescription, actionTips, actionImage: String     let actionSponsor, actionSponsorURL: String Now I am preparing a segue to a detail ViewController but is giving me an error.  func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {             performSegue(withIdentifier: "showDetail", sender: self)        }         override func prepare(for segue: UIStoryboardSegue, sender: Any?) {             if let destination = segue.destination as? ActionDetailViewController {                 destination.action = result?.data3.actions[(tableView.indexPathForSelectedRow?.row)!] Error description. Value of type '[Datum]' has no member 'actions' Who can help me?
Posted
by
Post not yet marked as solved
0 Replies
167 Views
Hello, I have a folder that has multiple mp3 files inside. I want to export this folder to a location wherever user wants with an extension (I don't know which one would be best). That exported folder must be reusable. I mean I must be able to import that exported folder into another device to use mp3 files that it stored. So how can I export this folder in swift ? Any idea would be great. Thanks in advance
Posted
by
Post not yet marked as solved
2 Replies
232 Views
struct ModelsByCategoryGrid: View { 2. @Binding var showBrowse: Bool 3. let models = Models()     4. var body: some View { 5.    VStack { ForEach(ModelCategory.allCases, id: \.self) { category in                    //Only display the grid if the category contains items 7.  if let modelsByCategory = models.get(category: category) {   8. HorizontalGrid(showbrowse: $showBrowse, title: category.label, items: modelsByCategory)         } I GET AN ERROR FOR LINE 5 SAYING "MISSING ARGUMENT FOR PARAMETER IN #1 CALL"
Posted
by
Post not yet marked as solved
1 Replies
183 Views
var body: some View {      VStack {                ForEach(ModelCategory.allCases, id: .self) { category in [The error occurs for this ForEach command and it says: "Missing argument for parameter #1 in call"]                    //Only display the grid if the category contains items          if let modelsByCategory = models.get(category: category) {           HorizontalGrid(showbrowse: $showBrowse, title: category.label, items: modelsByCategory)          }        }      }   }
Posted
by
Post not yet marked as solved
1 Replies
196 Views
struct ModelsByCategoryGrid: View {   @Binding var showBrowse: Bool   let models = Models()       var body: some View {     VStack { [ONE ERROR HERE SAYS "Type'(_) -> ()' cannot conform to 'View']       ForEach(ModelCategory.allCases, id: .self); { category in [2 ERRORS HERE SAY 1: "Generic parameter 'Content' could not be inferred" 2: "Missing argument for parameter 'content' in call                   //Only display the grid if the category contains items         if let modelsByCategory = models.get(category: category) {           HorizontalGrid(showbrowse: $showBrowse, title: category.label, items: modelsByCategory)         }       }     }   } }
Posted
by
Post not yet marked as solved
0 Replies
229 Views
What we required, to remind the task daily in the application, have the notification(s) repeat daily at the same time using hour, minutes components with UNCalendarNotificationTrigger, and once the task is done by the user the repeat notification for the current day should be stopped and notification(s) on next day must be repeated as expected on an hourly interval. We used UNCalendarNotificationTrigger as following statements, let fireDate = Calendar.current.dateComponents([.hour, .minute], from: trigger_date) let trigger = UNCalendarNotificationTrigger(dateMatching: fireDate, repeats: true) Note: Above scenario is working with deprecated UILocalNotification framework but not working UserNotifications framework. Your help/comment will be appreciable.
Posted
by
Post not yet marked as solved
0 Replies
341 Views
I'm using the AVPlayer to streaming video, same as: let strURL = "https://multiplatform-f.akamaihd.net/i/multi/will/bunny/big_buck_bunny_,640x360_400,640x360_700,640x360_1000,950x540_1500,.f4v.csmil/master.m3u8"             if let url = URL(string: strURL) {                 let asset = AVAsset(url: url)                 let playerItem = AVPlayerItem(asset: asset)                 player = AVPlayer(playerItem: playerItem)                 let layer = AVPlayerLayer(player: player)                 layer.frame = viewPlaying.bounds                 viewPlaying.layer.addSublayer(layer)                 player?.playImmediately(atRate: 4.0)             } The video can't play, it'll play normal with rate <= 2.0 on iOS 15.x. Anybody can give me the advise to fix this issue?
Posted
by
Post not yet marked as solved
1 Replies
309 Views
The TabularData framework is pretty new (and I am new to Swift), so I haven't found much documentation on the internet. I need to import data from small spreadsheets (converted to .csv), and would like to use DataFrame but am running into the problem that a function cannot return an array (unless there is a premade struct to handle it). My csv files are small and only strings, but they change every day...I have up till now been reading them in line by line, but hope to use the new framework. print(dataframe) gives me just what I want, is there any way to inject it into my app without reading line by line? if let testUrl = Bundle.main.url(forResource: "Timeslot template", withExtension: "csv") {     do{       let tsArray = try DataFrame(contentsOfCSVFile: testUrl, options: options)       print(tsArray) //How can I get this output into an array in the app?                    } catch {       print(error)            }   }
Posted
by
Post not yet marked as solved
1 Replies
284 Views
Hi all I've been a web developer for quite some time, and last year I start diving into this "Swift" and "SwiftUI" app development thing. While I mainly focus on app development, there are some options on framework/language to choose: React, Flutter, Swift, Android. I also have moderate experience on other language like Python, PHP, JS, Go etc etc. Up to this moment and this version of Swift (v5), the development experiences of Swift is: Worst. I can only see that Swift is making simple things complicated, and difficult to read. For example, a simple ForEach loop: In PHP: foreach($list_of_items as $item){ ... } But in Swift: ForEach(0 .. <5){ item in ... } At the first glance, it is so weird to put item outside the ForEach loop, until we read further and know that item is a parameter. I don't even know what the in keyword is all about. But if you are using format like PHP, you don't need another keyword in. And this is how Swift write try...catch do { try checkPassword("password") print("That password is good!") } catch { print("You can't use that password.") } Why can't Swift just do this, just like other programming language (Python, PHP)? try{ ... }catch{ ... } We can save another keyword do And do you know how to use Camera features in iOS app? The template code is long and there are a lot of settings before writing the code so I don't put it here. And actually, there are some 3rd parties Camera libraries that do the same thing?! That simplify the setup process. Why can we use Swift native camera function like this: objCamera = new Camera(some_configs) objCamera.takePicture() objCamera.close() This really make me walk away from Swift. So, here is my little suggestion: I hope that the next version of Swift can make things less complicated, and easy to use. I'm not talking about syntax sugar, but really, writing easy to understand program is actually the joy of development. Thank you.
Posted
by
Post not yet marked as solved
0 Replies
265 Views
I have an older iMac that can’t support swift 5.5. what is it about 5.5 that makes it impossible to run on an older machine ?
Posted
by
Post not yet marked as solved
1 Replies
357 Views
I'm pulling data from Firestore and listing it in my table. However, according to the conditions in the data I have taken, the color or touch of the data in my table must change. In the codes I wrote, this works, but sometimes the data does not come and naturally the table is not updated. Or when I scroll the list the data comes and the list is updated. How can I do this without problems? I am posting my codes and screenshot. when i choose the date not working when i select a date again it shows the error "[UICollectionViewRecursion] cv == 0x1088d4600 Disabling recursion trigger logging" when no data is received. please someone help me by changing my codes or showing me a different way.
Posted
by
Post not yet marked as solved
0 Replies
816 Views
Hi, I am updating our app to use the UITabBarAppearance() to set the standardAppearance and scrollEdgeAppearance for our tab bar, since compiling with Xcode 13 on iOS 15 devices breaks our ui when using the old approach. However I am running into a problem with setting the badge ui on the tab bar items. I have two tabs that need to be able to show a badge, and we want the badge ui to be different. One tabs badge should have a black background with white text, and the other tabs badge should have a grey background with black text. This used to work by just setting the tabBarItem.badgeColor and tabBarItem.setBadgeTextAttributes() but that no longer works with UITabBarAppearance(). So far I have only found a way to set the badge background and text color generally for all tabs by setting the stackedLayoutAppearance: private func setupTabBar() { let tabBar = UITabBar.appearance() let tabBarAppearance = UITabBarAppearance() tabBarAppearance.configureWithOpaqueBackground() tabBarAppearance.backgroundColor = .white let tabBarItemAppearance = UITabBarItemAppearance() tabBarItemAppearance.normal.badgeTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white] tabBarItemAppearance.normal.badgeBackgroundColor = UIColor.black tabBarAppearance.stackedLayoutAppearance = tabBarItemAppearance tabBar.standardAppearance = tabBarAppearance if #available(iOS 15, *) { tabBar.scrollEdgeAppearance = tabBarAppearance } } So I wanted to ask if it is even still possible to set individual badge colors on the tab bar items?
Posted
by
Post not yet marked as solved
0 Replies
303 Views
In iOS 15, the SwiftUI List view adds extra separators to fill the empty space when there are not enough rows (please see attached). These happens on MacOS but does not occur when the same code is run on iPadOS. I am using the new bindable List. I am seeing this on MacOS Monterey. How do I remove the extra separators?
Posted
by
Post not yet marked as solved
4 Replies
962 Views
Not sure how to accurately describe this so I apologize for the vague-ness, but in a SwiftUI app built on iOS 15, when users select a NavigationLink from a list, the app freezes. BUT, this only happens on some iPhone 12 and 13's. This does not happen on any iPhone I have personally tested (11, 12, 12 pro max, etc) but users have sent me video of it happening. In addition to this, the view that this nav link opens, DOES work for these users when it goes through another level of navigation. So for this user: MainView-&gt;ThisView : this action freezes MainView-&gt;AnotherView-&gt;ThisView : This action works Whereas 90% of other users, the nav link works fine and as expected. One user submitted a crash log from TestFlight which shows the following information, but I am not sure what this is indicating: #0 (null) in specialized _ArrayBuffer._consumeAndCreateNew+ 507128 (bufferIsUnique:minimumCapacity:growForAppend:) () #1 (null) in DisplayList.ViewUpdater.Model.State.addClip+ 663792 (_:style:) () #2 (null) in static DisplayList.ViewUpdater.Model.merge+ 1281064 (item:into:) () #3 (null) in DisplayList.ViewUpdater.updateInheritedView+ 421056 (container:from:parentState:) () #4 (null) in DisplayList.ViewUpdater.update+ 196956 (container:from:parentState:) () #5 (null) in DisplayList.ViewUpdater.updateInheritedView+ 421432 (container:from:parentState:) () #6 (null) in DisplayList.ViewUpdater.update+ 196956 (container:from:parentState:) () #7 (null) in closure #1 in DisplayList.ViewUpdater.render+ 149008 (rootView:from:time:version:maxVersion:contentsScale:) () #8 (null) in DisplayList.ViewUpdater.render+ 67780 (rootView:from:time:version:maxVersion:contentsScale:) () #9 (null) in DisplayList.ViewRenderer.render+ 779076 (rootView:from:time:nextTime:version:maxVersion:contentsScale:) () #10 (null) in closure #1 in UIHostingView.renderDisplayList+ 967228 (:asynchronously:time:nextTime:version:maxVersion:) () #11 (null) in UIHostingView.renderDisplayList+ 408916 (:asynchronously:time:nextTime:version:maxVersion:) () #12 (null) in closure #1 in ViewRendererHost.render+ 94160 (interval:updateDisplayList:) () #13 (null) in ViewRendererHost.render+ 905080 (interval:updateDisplayList:) () #14 (null) in _UIHostingView.layoutSubviews+ 167448 () () #15 (null) in @objc _UIHostingView.layoutSubviews+ 183076 () () #16 (null) in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] () #17 (null) in CA::Layer::layout_if_needed(CA::Transaction*) () #18 (null) in CA::Layer::layout_and_display_if_needed(CA::Transaction*) () #19 (null) in CA::Context::commit_transaction(CA::Transaction*, double, double*) () #20 (null) in CA::Transaction::commit() () #21 (null) in _UIApplicationFlushCATransaction () #22 (null) in _UIUpdateSequenceRun () #23 (null) in schedulerStepScheduledMainSection () #24 (null) in runloopSourceCallback () #25 (null) in CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION () #26 (null) in __CFRunLoopDoSource0 () #27 (null) in __CFRunLoopDoSources0 () #28 (null) in __CFRunLoopRun () #29 (null) in CFRunLoopRunSpecific () #30 (null) in GSEventRunModal () #31 (null) in -[UIApplication _run] () #32 (null) in UIApplicationMain () #33 (null) in 0x100b6c000 () #34 (null) in start () Can anyone point me in the right direction to start trying to figure out what is causing this issue? Any insight is appreciated.
Posted
by
Post not yet marked as solved
0 Replies
291 Views
Hi there, I am trying to upload my AR experience from Reality Composer into XCode using Swift. Although I have followed the documentation from Apple's presentation, minute 40:53, (https://developer.apple.com/videos/play/wwdc2019/609/?time=2453) of working with AR and XCode, I receive an error message every time I try to load my scene, as the load prompt seems to become part of the scene title and my title itself is not recognized. For example: Module '...' has no member named 'load...'. If anyone can help me here, I would be very grateful.
Posted
by