Swift

433 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 2 years ago
MODERATORS
101
102
103
104
105
106
107
 
 

Hey all! I've been writing up a series on the changes coming to Swift 6 related to concurrency. Thought I'd start sharing them here too.

108
109
110
111
112
113
 
 

cross-posted from: https://programming.dev/post/3558087

Type parameter packs and value parameter packs allow you to write a generic function that accepts an arbitrary number of arguments with distinct types. As a result of SE-393, SE-398, and SE-399, you can use this new feature from Swift 5.9.

114
 
 

Hi,

I thought we could make a list of open source Swift projects that's open to public contribution. Which is one of the most effective ways to really learn programming.

We could follow this template to make it easy for readers:

Title in Bold

Short Description:

Link:

115
116
 
 

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....

117
 
 

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!

118
119
 
 

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.

120
121
122
123
 
 

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

124
125
 
 

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:
view more: ‹ prev next ›