I created a data structure based on a dictionary of words. The purpose is to link each word to all other words made up of the same letters plus one.
Example: table -> ablate, cablet, tabled, gablet, albeit, albite, etc.
For this I built a data model made of three entities: Word, Draw, Link.
A Draw is a set of letters corresponding to a Word and sorted in alphabetic order, like : HOUSE -> EHOSU. A Link is a letter that you add to a Draw to get another Draw.
So my data model looks like this:
And here is how I implemented it in Xcode:
Entity Word
(let's forget the attribute optComp that plays no role here)
Entity Draw
Entity Link
I am populating the data in two steps:
first I read a list of words from a .txt source and I populate the Word entity and at the same time the Draw entity with the corresponding relationship (function loadDic())
This first step apparently works fine. I can easily find all anagrams of any word with something like word.sort.word.spelling
I read through the Draw entity. For each draw I seek all existing +1 draws considering each letter of the alphabet. If there are, I create a Link and add the relationships (function createLinks())
Here is where something goes wrong. If the Link's and the relationship Draw.plus seem to be correctly created, the other relationship Link.gives is only partially populated, say 50%.
Moreover, I tried to apply an additional routine (updateLinks()) , focusing only on Link's with an empty Link.gives relationship and updating them. But again, only 50% of the nil relationships appear to be populated.
I could not find out why those relationships are not properly populated. If someone can help me out I would be grateful.
Here is the code:
LoadDic() function (OK) :
func loadDic() {
print("Loading dictionary...")
dataAlreadyLoaded.toggle()
guard let url = Bundle.main.url(forResource: INPUT_FILE, withExtension: "txt") else {
fatalError("\(INPUT_FILE).txt not found")
}
if let dico = try? String(contentsOf: url, encoding: String.Encoding.utf8 ) {
let lines = dico.split(separator: "\r\n")
for line in lines {
let lineArray = line.split(separator: " ")
print("\(lineArray[0])") // word
let wordSorted = String(lineArray[0].sorted())
let draw = getDraw(drawLetters: wordSorted) ?? addDraw(drawLetters: wordSorted) // look if draw already exists, otherwise create new one.
let wordItem = Word(context: viewContext) // create word entry with to-one-relationship to draw
wordItem.spelling = String(lineArray[0])
wordItem.optComp = (Int(String(lineArray[1])) == 1)
wordItem.sort = draw
do {
try viewContext.save()
} catch {
print("Errort saving ods9: \(error)")
}
}
}
print("Ods Chargé")
}
func addDraw(drawLetters: String) -> Draw {
let newDraw = Draw(context: viewContext)
newDraw.draw = drawLetters
return(newDraw)
}
func getDraw(drawLetters: String) -> Draw? {
let request: NSFetchRequest<Draw> = Draw.fetchRequest()
request.entity = Draw.entity()
request.predicate = NSPredicate(format: "draw == %@", drawLetters)
do {
let drw = try viewContext.fetch(request)
return drw.isEmpty ? nil : drw[0]
} catch {
print("Erreur recherche Tirage")
return nil
}
}
createLinks() function (NOK):
func createLinks() {
var erreur = " fetch request <Draw>"
let request: NSFetchRequest<Draw> = Draw.fetchRequest()
request.entity = Draw.entity()
request.predicate = NSPredicate(value: true)
print("Building relationships...")
do {
let draws = try viewContext.fetch(request)
count = draws.count
for draw in draws {
print("\(count) - \(draw.draw!)")
linkTable.removeAll()
for letter in ALPHABET {
print(letter)
let drawLettersPlus = String((draw.draw! + String(letter)).sorted()) // draw with one more letter
if let drawPlus = draws.first(where: { $0.draw == drawLettersPlus }) { // look for Draw entity that matches augmented draw
let linkItem = Link(context: viewContext) // if found, create new link based on letter with relationship to augmented draw
linkItem.letter = String(letter)
linkItem.gives = drawPlus
erreur = " saving \(draw.draw!) + \(letter)"
try viewContext.save()
linkTable.append(linkItem) // saves link to populate the one-to-many relationship of the initial draw, once the alphabet is through
}
}
let drawUpdate = draw as NSManagedObject // populate the one-to-many relationship of the initial draw
let linkSet = Set(linkTable) as NSSet
drawUpdate.setValue(linkSet, forKey: "plus")
erreur = " saving \(draw.draw!) links plus"
try viewContext.save()
count -= 1 // next draw
}
} catch {
print("Error " + erreur)
}
print("Graph completed")
}
updateLinks function (NOK):
func updateLinks() {
var erreur = "fetch request <Link>"
let request: NSFetchRequest<Link> = Link.fetchRequest()
request.entity = Link.entity()
print("Running patch...")
do {
request.predicate = NSPredicate(format: "gives == nil")
let links = try viewContext.fetch(request)
for link in links {
let baseDraw = link.back!.draw!
print("\(baseDraw) \(link.letter!)")
let augmDrawLetters = String((baseDraw + link.letter!).sorted())
if let augmDraw = getDraw(drawLetters: augmDrawLetters) {
viewContext.perform {
let updateLink = link as NSManagedObject
updateLink.setValue(augmDraw, forKey: "gives")
erreur = " saving \(augmDraw.draw!) \(link.letter!)"
do {
try viewContext.save()
} catch {
print("Erreur mise à jour lien")
}
}
}
}
} catch {
print("Error " + erreur)
}
}
RESULT
And this is the output showing the content of the Draw entity with relationships after createLinks() is applied:
And here after updateLinks() is applied :
Explore the art and science of app design. Discuss user interface (UI) design principles, user experience (UX) best practices, and share design resources and inspiration.
Post
Replies
Boosts
Views
Activity
Is there any way to lock the clock in Standby so it doesn't change? It is so frustrating when I put the phone on the charger and have to scroll back and forth, trying to find the clock I would like to use all the time.
While doing production release of app, I was not able to see phase release option like in my previous releases. Due To whihc when I released. the app , it got released to 100% users. I want to know why phase release option was not showing up in my dashboard
I am developing an app that requires calling the iPhone's Face ID module to scan users' facial data. Where can I find Apple's design resources and guidelines for Face ID? The Face ID resources available in Figma are incomplete, and I need more support.
For example, in the iPhone settings, the scenario: the UI interface for scanning the user's face to collect data, specifically the circular design in the "How to Set Up Face ID" screen.
The most recent update included coloured icons for grouping of emails
anybody previously needing to group emails we’re able to achieve this alphabetically by simply searching for what you were looking for.
These icons clutter the page with totally unnecessary screen pollution.
if you want to persist with this folly can you please provide a classic display option for those of us who have happily survived using email for 30 years without this fluff.
Hello,
I recently submitted my app to the Apple Store and received a rejection under Guideline 4.3(a) - Design - Spam, stating that my app is similar to others on the store. However, my app has a unique feature set, offers more functionality and content than competitors, and is completely free with ad monetization, unlike most similar apps that require subscriptions.
I have spent five months developing this app from scratch, ensuring it provides an original and valuable experience for users. I did not use an app template or repackaged code, and my app is not a reskinned version of any existing app. I genuinely believe it brings meaningful differentiation to the market.
I would appreciate any guidance on how I can better communicate my app’s uniqueness to the review team or what specific aspects I should adjust to comply with Apple's guidelines.
Thank you for your time and support.
I have completed a code with chatgpt and I am unising the latest version of code. i am also using an m1 MacBook air (2020). would love to know if anyone have resolved this issue. by using the ai to correct the code it disrupts it with something. an incorrect imoout line,but after multiple attempts ai get it right. I have notice that the code shows up on the start meaning run, take some time to load the intro page.
Hello
So I have an application which is in the Apple store. I wanted to fixe some issue therefore i created update build with the following:
• Reworked Character Physics: Improved responsiveness and movement for smoother, more controlled gameplay.
• Bug Fixes & Performance Enhancements: Fixed critical issues affecting gameplay consistency and stability. Players will now experience better performance and more accurate controls.
• Mac Catalyst Fixes: Improved support for macOS, fixing issues related to UI scaling and responsiveness.
The changes above are basically all there is. Now it seems that i am not able to pass review as it constantly marks design spam and not give anything in particular. Whats up with that ?
Hello everyone! The Swift Student Challenge officially starts tomorrow (February 3rd), and I have a question. Am I allowed to use tools like Photoshop to create artwork for my project? I’d appreciate any clarification. Thanks in advance!
I've been losing countless hours of work trying to create a variable-width SF Symbol that supports interpolation, no dice. Both Sketch and Figma output SVGs that are not interpolatable.
After numerous hours of research, I believe it's due to the fact that when outlining strokes, these editing tools introduce artifacts into the shapes — sometimes I get very short line segments where there would not be needed, sometimes a 3-point curve gets expanded to a 4-point curve, but not in all weights. It's always inconsistent.
So my only question is rather simple: what's the graphic editing tool Apple uses to create hundreds of symbols? Clearly you cannot edit the stroke of ALL curves by hand, it's inhumane.
Sketch? Figma? Illustrator? Inkscape? Affinity? I'd like a definitive answer from someone internal so that I can at least try to use the same tool as you without wasting more hours.
We are working on one of the projects for Hackathon for which we need to access the 3D Models of Apple Watch, it will help in making our project more realistic and effective, I wanted to know if we can get access for the same.
Hi community,
I have a question regarding MusicKit, is it necessary to follow a design guideline to integrate this framework into my App?
Also, when no music is reproducing in MusicKit which placeholder we should show, do you provide the resource? Or can we create our own placeholder?
Thanks for all,
David.
Hi everyone, I'm currently working on my own Apple TV app. So far, things are going pretty well, but right now, I'm stuck on the design of the categories or selection menus.
Here's a screenshot of how it looks right now:
The green color and the border are intentionally added for now so I can see what is where. My actual goal is to remove the gray bar (or is this the "main bar"?). The pink bar and its border are just design elements that can be removed if needed. I want it to look more "original," like this:
Here is the code:
let title: String
let isSelected: Bool
var body: some View {
HStack {
Text(title)
.foregroundColor(isSelected ? .black : .white)
.font(.system(size: 22, weight: .regular))
.padding(.leading, 20)
Spacer()
Image(systemName: "chevron.right")
.foregroundColor(isSelected ? .black : .gray)
.padding(.trailing, 20)
}
.frame(height: 50) // Einheitliche Höhe für die Kategorien
.background(Color.pink) // Innerer Hintergrund auf pink gesetzt
.cornerRadius(10) // Abrundung direkt auf den Hintergrund anwenden
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color.green, lineWidth: 3) // Äußerer Rahmen auf grün gesetzt
)
.padding(.horizontal, 0) // Entferne äußere Ränder
.background(Color.clear) // Entferne alle anderen Hintergründe
}
}
struct SettingsView_Previews: PreviewProvider {
static var previews: some View {
SettingsView()
}
}
I’ve adjusted the code, but it’s still not quite right. When a category is not selected, it appears black instead of gray, like in the original design
Here is the code:
struct SettingsView: View {
@State private var selectedCategory: String?
var body: some View {
NavigationStack {
ZStack {
Color.black
.edgesIgnoringSafeArea(.all)
VStack(spacing: 0) {
// Überschrift oben in der Mitte
Text("Einstellungen")
.font(.system(size: 40, weight: .semibold))
.foregroundColor(.white)
.padding(.top, 30)
HStack {
// Linke Seite mit Logo
VStack {
Spacer()
Image(systemName: "applelogo")
.resizable()
.scaledToFit()
.frame(width: 120, height: 120)
.foregroundColor(.white)
Spacer()
}
.frame(width: UIScreen.main.bounds.width * 0.4)
// Rechte Seite mit Kategorien
VStack(spacing: 15) {
ForEach(categories, id: \.self) { category in
NavigationLink(
value: category,
label: {
SettingsCategoryView(
title: category,
isSelected: selectedCategory == category
)
}
)
.buttonStyle(PlainButtonStyle())
}
}
.frame(width: UIScreen.main.bounds.width * 0.5)
}
}
}
.navigationDestination(for: String.self) { value in
Text("\(value)-Ansicht")
.font(.title)
.foregroundColor(.white)
.navigationTitle(value)
}
}
}
private var categories: [String] {
["Allgemein", "Benutzer:innen und Accounts", "Video und Audio", "Bildschirmschoner", "AirPlay und HomeKit", "Fernbedienungen und Geräte", "Apps", "Netzwerk", "System", "Entwickler"]
}
}
struct SettingsCategoryView: View {
let title: String
let isSelected: Bool
var body: some View {
HStack {
Text(title)
.foregroundColor(.white)
.font(.system(size: 22, weight: .medium))
.padding(.leading, 20)
Spacer()
Image(systemName: "chevron.right")
.foregroundColor(.gray)
.padding(.trailing, 20)
}
.frame(height: 50) // Einheitliche Höhe für die Kategorien
.background(isSelected ? Color.gray.opacity(0.3) : Color.clear) // Hervorhebung des ausgewählten Elements
.cornerRadius(8) // Abgerundete Ecken
.scaleEffect(isSelected ? 1.05 : 1.0) // Fokus-Animation
.animation(.easeInOut, value: isSelected)
}
}
struct SettingsView_Previews: PreviewProvider {
static var previews: some View {
SettingsView()
}
}
I am creating a Generate note app but I don't see the text in the button when I applied the MeshGradient. I removed the Mesh Gradient and text is there. Need some help to find the issue. I am new to app Development and I am learning how to use it. Below is the code:
import SwiftUI
struct ContentView: View {
@State private var inputText: String = ""
@State private var isLoading: Bool = false
var body: some View {
ZStack {
Color(.systemGray6).edgesIgnoringSafeArea(.all)
VStack (spacing: 20) {
Text("Generate Notes")
.font(.title)
.fontWeight(.bold)
.frame(maxWidth: .infinity, alignment: .leading)
Text("Transform your thoughts into well-structured notes using artificial intelligence.")
.font(.subheadline)
.foregroundStyle(.secondary)
.frame(maxWidth: .infinity, alignment: .leading)
TextEditor(text: $inputText)
.frame(height: 200)
.padding()
.background(RoundedRectangle(cornerRadius: 16)
.fill(Color(.systemGray6)))
Button(action: {}) {
HStack {
if isLoading {
ProgressView()
.tint(.white)
} else {
Image(systemName: "sparkles")
}
Text(isLoading ? "Generating..." : "Generate Notes")
}
.padding()
.frame(maxWidth: .infinity)
.background(
MeshGradient(width: 3, height: 3, points: [
.init(0, 0), .init(0.5, 0), .init(1, 0),
.init(0, 0.5), .init(0.5, 0.5), .init(1, 0.5),
.init(0, 1), .init(0.5, 1), .init(1, 1)
], colors: [
.blue, .purple, .indigo,
.orange, .white, .blue,
.yellow, .green, .mint
])
)
.mask(
RoundedRectangle(cornerRadius: 16)
.stroke(lineWidth: 16)
.blur(radius: 8)
)
.overlay(
RoundedRectangle(cornerRadius: 16)
.stroke(.white, lineWidth: 1)
.blur(radius: 1)
.blendMode(.overlay)
)
.background(.black)
.foregroundColor(.white)
.cornerRadius(16)
.background(
RoundedRectangle(cornerRadius: 16)
.stroke(.black.opacity(0.5), lineWidth: 1)
)
.shadow(color: .black.opacity(0.15), radius: 20, x: 0, y: 20)
.shadow(color: .black.opacity(0.1), radius: 15, x: 0, y: 15)
}
.disabled(isLoading || inputText.isEmpty)
Spacer()
}
.padding(32)
.background(Color(.systemBackground))
.cornerRadius(44)
.shadow(color: .black.opacity(0.1), radius: 20, x:0, y:10)
}
}
}
#Preview {
ContentView()
}
Hi! I've detected that in iOS18 launch screen colors differs from the defined ones, that is, if I create a launch screen with a color like #ff0000 (red) and the initial view controller is a view controller with the same color as background, I can see the transition between launch screen and the initial view controller because the launch screen color is different from the other one (dark in this case).
I've tested it with several colors: left side is the launch screen and right side is the initial view controller. Both views created with IB using the same colors (it also happens with background images using colors)
Is this an intentionall behavior? If so, theres a way to disable it? I need the transition between the launch screen and my initial view controller to be non perceptible...
Thanks!
I recently submitted a new app for review, but it has been rejected multiple times for vague reasons. The most recent rejection reason I received was unclear, leaving me unsure of what improvements are needed to get the app approved for the App Store.
Does anyone have any advice on how to address this?
Additionally, to Apple reviewers: Could you please provide more detailed feedback to help developers improve their apps? The repeated review process takes a significant amount of time, and guessing what needs to be fixed without clear guidance makes it even more challenging.
#################################
The latest rejection reason I got is:
Guideline 4.0 - Design
We noticed an issue in your app that contributes to a lower-quality user experience than App Store users expect:
Your app included hard to read type or typography.
Since App Store users expect apps to be simple, refined, and easy to use, we want to call your attention to this design issue so you can make the appropriate changes.
Next Steps
Please revise your app to address all instances of the issue identified above.
Hello,
I want to make an app that displays the current event(s) (The ones that are ongoing at any given moment) on my Google calendar and shows how far through the event(s) I am with a progress bar, and updates live.
I want it to be as simple as possible and don't want it to take up too much space. I have a little window with some text elements and a progress bar that works if you manually put in values. But I still think the window is too big and clunky and I wonder if it's possible to change it's style?
I'm a bit inexperienced with coding and am completely new to xcode and swift. What approach would you recommend I take with this project? Or what resources would you refer me to?
Our custom ble based app starts a service uuid beacon to advertise. When the app is put in background, the beacon is shifted to another beacon and a specific beacon data is put in the scan response one example is like: 0x14FF4C000100000000000000000000000000040000
I want to know what is the format of this beacon. I can see its a manufacturer type data with apple company id and beacon type is 0x01. I want to know what this type means and how is the data which follows is calculated.
Helvetica (17.0d1e1) has bugs, hopefully the developers and designers will fix it.
Link to the presentation: https://drive.google.com/file/d/16qfpo9Y7Psghv5c_Xl3JBiTPkP4QNaaS/view?usp=sharing
I'm working to emulate the Activity Rings featured in Apple's Fitness app.
Here's a copy of what's in the swift file so far.
//
// ProgressRingPrototype.swift
// Nutrition
//
// Created by Derek Chestnut on 1/13/25.
//
import SwiftUI
struct ProgressRingPrototype: View {
@State var progress = 0.00
let size: CGSize
let thickness: CGFloat
var color: Color?
var gradientColors: [Color]?
var body: some View {
let color = color ?? .primary
ZStack {
RingPrototype(
size: self.size,
thickness: self.thickness,
color: color.opacity(0.2)
)
let gradient = AngularGradient(
colors: gradientColors ?? [.primary, .secondary],
center: .center
)
let style = StrokeStyle(
lineWidth: 32,
lineCap: .round
)
Circle()
.trim(from: 0, to: progress)
.stroke(gradient, style: style)
.rotationEffect(.degrees(-90))
.frame(width: size.width, height: size.height)
}
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
withAnimation(.easeInOut(duration: 1)) {
progress = 0.75
}
}
}
}
}
#Preview {
ZStack {
ProgressRingPrototype(
progress: 0.1,
size: CGSize(width: 256, height: 256),
thickness: CGFloat(32),
color: .primary
)
ProgressRingPrototype(
progress: 0.1,
size: CGSize(width: 190, height: 190),
thickness: CGFloat(32),
color: .primary
)
ProgressRingPrototype(
progress: 0.1,
size: CGSize(width: 124, height: 124),
thickness: CGFloat(32),
color: .primary
)
}
}
Here's a snapshot of the live preview.
I'm experiencing an issue where the trailing line cap generated by the stroke exceeds the start angle of the angular gradient, which creates an ugly artifact at 0 degrees.
Anyone have a solution to this problem?
Derek