Post

Replies

Boosts

Views

Activity

What is `classNamed(_:)` for?
There is a such method in Bundle: func classNamed(_ className: String) -> AnyClass? The description says it loads the Class object for className. It's, obviously, an Objective-C stuff. I started from Objective-C but didn't used it, preferring NSClassFromString. Now I suddenly tested it in various applications. I was surprised that it doesn't work in iOS apps neither in Playground: import Foundation class TalkingFruit {   func greet() {     print("Hello, playground")   } } @objc class LagacyFruit: NSObject { } print(Bundle.main.classNamed("TalkingFruit") ?? "no class") // no class print(Bundle.main.classNamed("LegacyFruit") ?? "no class") // no class print(Bundle.main.classNamed("NSObject") ?? "no class either") // no class either And now I have a question: Does it even work? And how it's supposed to be used? Working use case example would be great.
2
0
1.5k
Jan ’22
Xcode Preview Broken
On May 1 I started to see this image instead of watch UI preview. It worked well before. I didn't update Xcode, neither I deleted or installed any new simulator OS. It was harmful to my work, since simulator download is 4GB and I need to wait when it downloads, instead of reviewing PRs and closing tasks. Did anyone had the same issue? Do you know how to prevent it?
2
0
928
May ’24
CKModifyRecordsOperation records limit?
I'm trying to delete many records with one CKModifyRecordsOperation and getting this error: <CKError 0x600000dbe4f0: "Limit Exceeded" (27/1020); "Your request contains 552 items which is more than the maximum number of items in a single request (400)"> This obviously means, that Modify Operation has record limit of 400 which is equal to CKQueryOperation.maximumResults. The good solution here would be to chunk the array of records into subarrays with length less than 400 and add multiple delete operations to the database. The only problem is that the limit for CKModifyRecordsOperation is neither documented nor provided with a constant, so it's basically a magic number. In hope that my prayers would be heard I want to ask to add maximumResults constant to CKModifyRecordsOperation.
3
0
915
Dec ’23
Aggregated Data Table (Reporting Table) in CloudKit database
I need to track user actions, for example video view count. Then the data is used to get most popular videos for last 7 days, 30 days and for a year. For this purpose I have created a Downloads table with timestamp and video fields. Each time user opens the catalog, I'm running queries to get Downloads and sort the videos based on them. This is a working, but not the efficient solution. A good option is to add aggregated data table storing summary counts for the popular queries - countFor7Days, etc. This will improve query performance. But it requires a job that would update the aggregate table every day. The question is how to implement this job in CloudKit? Is there are such built-in feature, or I need a custom service running somewhere?
3
1
870
Feb ’24
How to reduce complication extension executable size?
Hello! I'm working on the watchOS app that provides user with multiple fancy complication sets. There are about 50 widgets in our WidgetBundle now. With this amount we reached memory limit and the app crashes: Thread 1: EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded) (limit=15 MB) I inspected complicationExtension.appex content and find out that most volume is occupied by the executable: Localized strings (12 langs) altogether - 165 KB Assets.car - 1.1 MB Imported fonts TTF files altogether - 866 KB complicationsExtension executable file - 8.2 MB Why it takes so much space and how can it be made smaller?
8
0
2.1k
Feb ’24