Post

Replies

Boosts

Views

Activity

URLRequest and gzip
From the Internet I read that URLRequest sends an Accept-Encoding header by default. I also read that URLSession auto decompresses any data that’s returned compressed. However these are what the internet says. I go to the Apple docs and read the URLSession & URLRequest sections but I can’t find where does it say that it sends the Accept-Encoding headers by default or that it auto decompresses compressed data. I know it does the latter as I am able to parse compressed data and have to do nothing to decompress. Just tell me where this stuff is documented by Apple so I can read about it.
1
0
2.6k
Aug ’17
PDFKit memory issue
I have a loop that iterates all pages in a PDF and saves parts of its content into core data. Problem seems to be that each PDFPage takes up around 30mb+ of memory. This memory is not retuned when the loop moves to ther next page. with large enough PDF in can cause out of memory crash.At first I thought it was something in the loop holidng a reference. However when I dont run the loop, or attempt to save any of the PDFPage contents and simply swipe through the PDFPages of the PDF, the memory still goes up 30mb + per page. So my question is how to clear the previous page from memory when no longer the page in view?I would add code but seems you cant pste into here so jist know its basic PDFKit code to load a pdf url
4
0
2.4k
Feb ’18
Ok Apple how to dismiss a SwiftUI Modal
I use UIHostingController inside my UIViewController to present a SwiftUI View. I have a button in that view which I want to tap and dismiss the presented view. How do I dimiss SwiftUI views when presented in a UIHostingController...{ let vc = UIHostingController(rootView: SwiftUIView()) present(vc, animated: true, completion: nil) }struct SwiftUIView : View { var body: some View { CustomButton() } }struct CustomButton: View { var body: some View { Button(action: { self.buttonAction() }) { Text(buttonTitle) } } func buttonAction(){ //dismiss the SwiftUIView when this button pressed } }
1
0
4.8k
Aug ’19
SwiftUI. Is there a standard?
In iOS when a button can be actioned it is coloured accordingly so the user knows to tap. This is a standard across the platform. Is there a standard for long press gestures? In the case of swiftUI the 3D Touch/ long press can show a contextMenu. How best to indicate to a user to long press? Is there a standard colour for example to show when an element is to be long pressed?
2
0
734
Feb ’20
Does anyone at Apple do quality control anymore?
Big Sur Beta 5 won't install for me or many others it seems. I'm on a 2017 iMac 5k. The iOS 14 betas have been absolutely terrible and my 3rd gen Apple Watch claims I have to delete files in order to install the latest beta on that. I have 0 songs, 15 phantom photos (no idea how to get rid of those) and just 6 apps. The update needs 2.9GB of space and despite having nothing on the watch really I only have 2.7GB free. There is no way for me to even clear some more space. I wouldn't mind or complain if I wasn't paying apple $99 to be a developer. Not to mention the thousands of $$ paid for the hardware. The very minimum we deserve is these betas are actually able to be installed.
0
0
316
Aug ’20
Page number of PDF in SwiftUI
I create a UIViewRepresentable to show my PDF inside my SwiftUI app. I want to access the current page number using currentPage?.pageRef?.pageNumber. from the view in which I display the pdf. How to make PDFView Created in func makeUIView(context: UIViewRepresentableContext<PDFDisplayRepresentedView>) -> PDFView Available in the view displaying the pdf so I can access its properties to obtain page number. import SwiftUI import PDFKit struct PDFDisplayView: View { @Binding var pdfDocument : PDFDocument? var body: some View { PDFDisplayRepresentedView(pdfDocument: pdfDocument!) } } struct PDFDisplayRepresentedView: UIViewRepresentable { let pdfDocument: PDFDocument init(pdfDocument: PDFDocument) { self.pdfDocument = pdfDocument } func makeUIView(context: UIViewRepresentableContext<PDFDisplayRepresentedView>) -> PDFView { return createPDFViewUsing(document: pdfDocument) } func updateUIView(_ pdfView: PDFView, context: UIViewRepresentableContext<PDFDisplayRepresentedView>) { pdfView.document = pdfDocument } private func createPDFViewUsing(document : PDFDocument) -> PDFView { let pdfView = PDFView(frame: CGRect(x: 0, y: 0, width: 100, height: 100)) pdfView.document = document ... set up pdfView attributes return pdfView } } view showing pdf where I want to know the page number pseudo code … @State private var pdfDisplayView : PDFDisplayView? …. var body: some View { load the pdf into this view. need to access the page number pdfDisplayView }
0
0
1.3k
May ’22
SwiftData .returnsDistinctResults ?
With NSFetchRequest of coreData it was possible to only return distinct results from the database with .returnsDistinctResults What if any is the fetch equivalent in SwiftData ? currently I'm appending entries into a Set<String>. Only with over 200k rows and no newBackgroundContext() in SwiftData the UI is locked for a number of seconds
1
0
608
Oct ’23
swiftData slow with large data
My database has over 100k entries and anytime I access it either via @Query or a custom Fetch request it freezes my apps UI for 10+ second. My first question is anyone having performance issues with large data sets. If so how have you found to resolve it ? My next question is does swiftUI load the entire database into memory with the @Query. As I feel it is seeing as my app becomes very slow and partially unresponsive. lastly if I have 2 data models and 1 has a to many relationship to the other are both loaded into memory even though only @Query 1? consider datamodels model1 { var name : String @Relationship(deleteRule:.cascade) var lotsOfData :[LotsOfData] init.... } LotsOfData{ var element1 : String var element2 : String var element3 : String var element4 : String var element4 : String init …. } LotsOfData has 100K instances in the database. if I @Query into model1 because it references LotsOfData through A relationship is all that data all called / loaded ? thanks for the information
1
4
1.7k
Oct ’23
Library Framework WebPrivacy missing MacOS Ventura
Not developer related but I can't find any help with google and trying to send a crash report to apple just causes spinning beachball. So hoping i can find some much needed help in this forum. Safari runs very slow and every time it launches i get an error producing the log below. Any fix suggestions please. Seeing a WebPrivacy library missing leaves me with no confidence using my mac. I had hoped a software update to Ventura 13.6.3 would resolve but no. Path: /Volumes/VOLUME/*/WebPrivacy.framework/Versions/A/XPCServices/com.apple.WebPrivacy.Service.xpc/Contents/MacOS/com.apple.WebPrivacy.Service Identifier: com.apple.WebPrivacy.Service Version: 34 (34.1.1) Build Info: WebPrivacy-34000000000000~249 (617C13) Code Type: X86-64 (Native) Parent Process: launchd [1] Responsible: Safari [5749] User ID: 501 Date/Time: 2023-11-15 09:15:24.5072 +0000 OS Version: macOS 13.6.3 (22G423) Report Version: 12 Anonymous UUID: EC45AED0-4F92-87DE-6EE8-AE74E4A4BD5E Sleep/Wake UUID: 65B3C137-4BC0-476B-9975-503694B76241 Time Awake Since Boot: 150000 seconds Time Since Wake: 88111 seconds System Integrity Protection: enabled Crashed Thread: 0 Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: Namespace DYLD, Code 1 Library missing Library not loaded: /System/Library/PrivateFrameworks/WebPrivacy.framework/Versions/A/WebPrivacy Referenced from: <BF03A141-E3B8-3EC8-B0D3-79F9E987841B> /Volumes/VOLUME/*/WebPrivacy.framework/Versions/A/XPCServices/com.apple.WebPrivacy.Service.xpc/Contents/MacOS/com.apple.WebPrivacy.Service Reason: tried: '/System/Library/PrivateFrameworks/WebPrivacy.framework/Versions/A/WebPrivacy' (no such file), '/System/Volumes/Preboot/Cryptexes/Incoming/OS/System/Library/PrivateFrameworks/WebPrivacy.framework/Versions/A/WebPrivacy' (no such file), '/System/Library/PrivateFrameworks/WebPrivacy.framework/Versions/A/WebPrivacy' (no such file, not in dyld cache), '/System/Library/Frameworks/WebPrivacy.framework/Versions/A/WebPrivacy' (no such file, not in dyld cache) (terminated at launch; ignore backtrace) Thread 0 Crashed: 0 dyld 0x7ff812633c52 __abort_with_payload + 10 1 dyld 0x7ff81264dfd7 abort_with_payload_wrapper_internal + 82 2 dyld 0x7ff81264e009 abort_with_payload + 9 3 dyld 0x7ff8125d28f0 dyld4::halt(char const*) + 375 4 dyld 0x7ff8125cfb71 dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) + 4526 5 dyld 0x7ff8125ce3bd start + 1805 Thread 0 crashed with X86 Thread State (64-bit): rax: 0x0000000002000209 rbx: 0x0000000000000000 rcx: 0x00007ff7b8f8a3c8 rdx: 0x00007ff7b8f8a830 rdi: 0x0000000000000006 rsi: 0x0000000000000001 rbp: 0x00007ff7b8f8a410 rsp: 0x00007ff7b8f8a3c8 r8: 0x00007ff7b8f8a430 r9: 0x0000000000000000 r10: 0x0000000000000127 r11: 0x0000000000000246 r12: 0x0000000000000127 r13: 0x00007ff7b8f8a830 r14: 0x0000000000000001 r15: 0x0000000000000006 rip: 0x00007ff812633c52 rfl: 0x0000000000000246 cr2: 0x0000000000000000 Logical CPU: 0 Error Code: 0x02000209 Trap Number: 133 Binary Images: 0x106f74000 - 0x106f8bfff com.apple.WebPrivacy.Service (34) <bf03a141-e3b8-3ec8-b0d3-79f9e987841b> /Volumes/VOLUME/*/WebPrivacy.framework/Versions/A/XPCServices/com.apple.WebPrivacy.Service.xpc/Contents/MacOS/com.apple.WebPrivacy.Service 0x7ff8125c8000 - 0x7ff8126605ef dyld (*) <d963b325-2b69-3e5a-ab79-8ce1662ec8cc> /usr/lib/dyld External Modification Summary: Calls made by other processes targeting this process: task_for_pid: 0 thread_create: 0 thread_set_state: 0 Calls made by this process: task_for_pid: 0 thread_create: 0 thread_set_state: 0 Calls made by all processes on this machine: task_for_pid: 153 thread_create: 0 thread_set_state: 5851 VM Region Summary: ReadOnly portion of Libraries: Total=171.8M resident=0K(0%) swapped_out_or_unallocated=171.8M(100%) Writable regions: Total=8452K written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=8452K(100%)
0
0
872
Nov ’23
Selecting which data models sync with iCloud SwiftData
So I am trying to sync only some of my Models with iCloud and others kept locally in the default.store. I am having a world of issues so before I start looking for the needle in my haystack. I would like to ask this forum, is my approach one that should work as desired or is my code obviously why things are not working? All my Models have default values and relationships where needed are optionals. iCloud is working but my issue arises when i try to exclude some models. So I want to sync "modelsForCloudSyncing" but not "modelNotForCloudSyncing" In advance thank you var avoidCloudSyncModelContainer : ModelContainer = { let modelNotForCloudSyncing = Schema([NoCloudSyncModel.self]) let modelConfigForNoCloudSync = ModelConfiguration(schema: modelNotForCloudSyncing, cloudKitDatabase: .none) let modelsForCloudSyncing = Schema([CloudSyncModelA.self, CloudSyncModelB.self, CloudSyncModelC.self]) let modelConfigForCloudSync = ModelConfiguration(schema: modelsForCloudSyncing, cloudKitDatabase: .automatic) do { return try ModelContainer(for: NoCloudSyncModel.self, CloudSyncModelA.self, CloudSyncModelB.self, CloudSyncModelC.self, configurations: modelConfigForNoCloudSync, modelConfigForCloudSync) } catch { fatalError("Could not create ModelContainer: \(error)") } }() ... { ContentView() }.modelContainer(avoidCloudSyncModelContainer)
11
2
1.8k
Nov ’23
Why does it not exist via @AppStorage
2 versions 1 works 1 doesn't. UIViewRepresentable to show a PDF @AppStorage(DefaultsKey.userActiveBook.rawValue) var activeBook : URL = Bundle.main.url(forResource: "BookPlaceHolder", withExtension: "pdf")! func makeUIView(context: Context) -&gt; PDFView { do { let pdfData = try Data(contentsOf: activeBook) pdfView.document = PDFDocument(data: pdfData) //&lt;---- is nil ... } catch let Error { print(Error) } } fails with Error Domain=NSCocoaErrorDomain Code=260 "The file “BookPlaceHolder.pdf” couldn’t be opened because there is no such file." func makeUIView(context: Context) -&gt; PDFView { do { let pdfData = try Data(contentsOf: Bundle.main.url(forResource: "BookPlaceHolder", withExtension: "pdf")!) pdfView.document = PDFDocument(data: pdfData) ... } catch let Error { print(Error) } } Works perfectly. What is it with using @AppStorage to access the exact same URL causing the discrepancies ?
2
0
693
Nov ’23
help needed understanding the apps file system
How often/ under what circumstances are users sandbox directory URL's changed? So I tried to save a URL to a document in @AppStorage @AppStorage(DefaultsKey.userActiveBook.rawValue) var activeBook : URL = Bundle.main.url(forResource: "BookPlaceHolder", withExtension: "pdf")! When user selects a new document activeBook is updated with the new URL. Issue is when the app relaunches from xCode the path to whatever is stored in activeBook changes. My work around so far is to just access the users Documents Directory via FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!. Then appending the last path component of activeBook. sidebar: obviously this doesn't work if the saved URL in activeBook is still the default from Bundle.main.url. I haven't written that workaround as yet. Am I only seeing issues in development due to a fresh relaunch via xCode? If the user only ever terminates the app on their device are the .documentDirectory URL's changing on each launch or do the remain constant? I don't want to write a workaround to ensure the correct URL for whats stored in @AppStorage, if the changing URL's only occurs due to launching from xCode which the end user wont ever encounter that edge case.
1
0
537
Nov ’23