String Pluralization in SwiftUI (Mind Blown 🤯) – iOS 2023

preview_player
Показать описание
Welcome to this exciting tutorial on String plurality in SwiftUI with inflection!

In this video, we'll be exploring the powerful tools that SwiftUI offers for working with strings in different pluralities. With SwiftUI's built-in support for inflection, you can easily adapt your app's interface to handle varying amounts of data in a way that feels natural to your users.

We'll start by diving into the basics of string pluralization and exploring some of the different rules and patterns that different languages use to handle plurals. Then, we'll move on to working with SwiftUI's powerful string interpolation and inflection features, allowing you to create dynamic, responsive user interfaces that can adapt to changes in data.

Throughout the video, we'll be providing plenty of real-world examples and practical tips for working with strings and inflection in SwiftUI. Whether you're a seasoned SwiftUI developer or just starting out, you'll find plenty of useful insights and techniques to help you create more flexible, user-friendly apps.

So if you're ready to take your SwiftUI skills to the next level, grab a cup of coffee and join us for this in-depth exploration of String plurality in SwiftUI with inflection!

** Popular Series

** Get Skillshare free for 2 Months and learn iOS

** Manage all your investments from app earnings on Betterment!

** Grow your own Youtube tech channel with TubeBuddy:

#swift #swiftUI #strings
Рекомендации по теме
Комментарии
Автор

THIS IS ACTUALLY MIND BLOWING holy swift!

krs
Автор

Thanks for the video. I had seen Paul Hudson's tutorial, but was inspired by yours to do a little more poking around. Here's what I discovered when I tried to make a predicate agree dynamically when the number of the subject changes. As long as the second word to be inflected is in the same string, this can be done using agreeWithArgument -- like this: Text("^[\(count) person](inflect: true) ^[is](agreeWithArgument: 1) here") which will results in variations like "1 person is here" and "2 people are here."

wadaienglish
Автор

There are more parameters than just inflect: true, you can also control if it interprets something like Post as a noun or a verb (3 Posts vs I posted an article). Simply use “^[\(count) Post](inflect: true, morphology: { partOfSpeech: \"noun\" })” to get the correct behaviour for a count of posts.

There is a WWDC video explaining things, you might have to do some searching for the documentation.

ShawnThroop
Автор

Thanks for the video. I just used this in my app ☺

femialiu
Автор

Does this only work in english? Is autotranslated to multiple languages?

directores
Автор

Does its work in English language only?

HZever
Автор

Anyone know if variables can be passed in to replace the "person/people" string? I'd like to pass people in as a data point and use inflection rather than hardcoding the text.

NoahGustafson-vh
Автор

Literally mind blowing!!! Thanks for sharing ❤

afaaqahmedsaqi
Автор

Can you please make a tutorial on creating a tableview (for instance a reminders app) and then sorting events in this tableview by time (so that the earlier even adds in the cell before the later event). There is nothing on youtube that shows you how to do sorting. Even videos on creating a phonebook don't go into the detail on how to sort names alphabetically.

calebgates
Автор

Here is a function to make plural(n, "person") work:

func plural(_ count: Int, _ word: String) -> String {
let locval: String.LocalizationValue = "^[\(count) \(word)](inflect: true)"
let r = locval).characters)
return r
}

markaurelius
Автор

Not sure i’ll ever use it. it can make debugging drastically harder if i know this is a static text and tried to search for the word “people” i might not figure out which line prints it unless i read the file line by line.

Amrhossam
Автор

I use Xcode 14.2, just like in the video - it's not working. I wrote this string extension: func pluralizeIfNeeded(count: Int)->String {
return "^[\(count) \(self)](inflect: true)"
}
Result of the testing function: testStringPluralization(): XCTAssertEqual failed: ("^[1 Document](inflect: true)") is not equal to ("Document")

DominikButz
Автор

This doesn't make any sense to me.. Is it trustworthy though? Multi language? What in the hell "inflect" means. Does this affect runtime performance? To be honest it is so many chars that ternary condition is the same size but you are more in control and it is more trustworhty. This could be promising but for now I think it's too weird.

danvilela