Swift

352 readers
1 users here now

This group focus on the content related to the development of Apple Eco-system software. So feel free to share and talk about, for example;

founded 1 year ago
MODERATORS
26
27
 
 

We’re excited to announce a new open source package called Swift HTTP Types.

Building upon insights from Swift on server, app developers, and the broader Swift community, Swift HTTP Types is designed to provide a shared set of currency types for client/server HTTP operations in Swift....

28
 
 

So I've got the following code, which seems to work, and I'm wondering if there is a better, cleaner way to approach adding/editing elements in an array.

var category: Category
var idx: Int = -1

switch mode {
case .add:
    category = Category()
case .edit(let _category):
    category = _category
    idx = categoryViewModel.categories.firstIndex(of: _category) ?? idx
}

category.name = categoryName
category.icon = "category-\(categoryIdx)"
category.color = colors[colorIdx]

switch mode {
case .add:
    categoryViewModel.categories.append(category)
case .edit:
    categoryViewModel.categories[idx] = category
}

I understand I'm not checking idx to make sure it's not -1. I'm not concerned about that part right now. It's the overall approach I'm looking for thoughts on.

Thanks!

29
30
 
 

Although at WWDC 2023, Apple will mainly focus on introducing the new data framework SwiftData, Core Data, as the cornerstone of SwiftData, has also been enhanced to some extent.

31
 
 

MainActor is a new attribute introduced in Swift 5.5 as a global actor providing an executor which performs its tasks on the main thread. When building apps, it’s essential to perform UI updating tasks on the main thread, which can sometimes be challenging when using several background threads. Using the @MainActor attribute will help ensure your UI is always updated on the main thread.

32
33
34
35
36
37
38
39
1
submitted 1 year ago* (last edited 1 year ago) by [email protected] to c/[email protected]
 
 

I have used a few SSG framework such as Next and Hugo, and my personal blog is built by Hugo which is based on GO programming language.

IME i've noticed the majority of SSG are based on Javascript and Typescript for some reason.

Never thought of Swift as an SSG, but it sounds interesting for me to play with and built a blog or something, and maybe even migrate my current blog to a swift-based SSG if they are as good as, say, Hugo.

Do you guys have any experience with Swift-SSG?

Edit: typos

40
41
42
43
 
 

Hi all,

Lets use this post to make a list of all free online courses and books that teach Swift programming.

Please post using the following template, to make easy for us to follow.

  • Title:
  • Author:
  • Description:
  • Link: