Foundation

RSS for tag

Access essential data types, collections, and operating-system services to define the base layer of functionality for your app using Foundation.

Posts under Foundation tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Networking Resources
General: TN3151 Choosing the right networking API Networking Overview document — Despite the fact that this is in the archive, this is still really useful. TLS for App Developers DevForums post Choosing a Network Debugging Tool documentation WWDC 2019 Session 712 Advances in Networking, Part 1 — This explains the concept of constrained networking, which is Apple’s preferred solution to questions like How do I check whether I’m on Wi-Fi? TN3135 Low-level networking on watchOS Adapt to changing network conditions tech talk Foundation networking: DevForums tags: Foundation, CFNetwork URL Loading System documentation — NSURLSession, or URLSession in Swift, is the recommended API for HTTP[S] on Apple platforms. Network framework: DevForums tag: Network Network framework documentation — Network framework is the recommended API for TCP, UDP, and QUIC on Apple platforms. Network Extension (including Wi-Fi on iOS): See Network Extension Resources Wi-Fi Fundamentals Wi-Fi on macOS: DevForums tag: Core WLAN Core WLAN framework documentation Wi-Fi Fundamentals Secure networking: DevForums tags: Security Apple Platform Security support document Preventing Insecure Network Connections documentation — This is all about App Transport Security (ATS). Available trusted root certificates for Apple operating systems support article Requirements for trusted certificates in iOS 13 and macOS 10.15 support article About upcoming limits on trusted certificates support article Apple’s Certificate Transparency policy support article Technote 2232 HTTPS Server Trust Evaluation Technote 2326 Creating Certificates for TLS Testing QA1948 HTTPS and Test Servers Miscellaneous: More network-related DevForums tags: 5G, QUIC, Bonjour On FTP DevForums post Using the Multicast Networking Additional Capability DevForums post Investigating Network Latency Problems DevForums post Local Network Privacy FAQ DevForums post Extra-ordinary Networking DevForums post Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com"
0
0
2.4k
Feb ’24
Interpreting received "Data" object in cpp
Hello Everyone, I have a use case where I wanted to interpret the "Data" object received as a part of my NWConnection's recv call. I have my interpretation logic in cpp so in swift I extract the pointer to the raw bytes from Data and pass it to cpp as a UnsafeMutableRawPointer. In cpp it is received as a void * where I typecast it to char * to read data byte by byte before framing a response. I am able to get the pointer of the bytes by using // Swift Code // pContent is the received Data if let content = pContent, !content.isEmpty { bytes = content.withUnsafeBytes { rawBufferPointer in guard let buffer = rawBufferPointer.baseAddress else { // return with null data. } // invoke cpp method to interpret data and trigger response. } // Cpp Code void InterpretResponse (void * pDataPointer, int pDataLength) { char * data = (char *) pDataPointer; for (int iterator = 0; iterator < pDataLength; ++iterator ) { std::cout << data<< std::endl; data++; } } When I pass this buffer to cpp, I am unable to interpret it properly. Can someone help me out here? Thanks :) Harshal
2
0
57
6h
NSAttributedString.enumerateAttribute(_:in) crashes with custom attribute in macOS Sequoia
The following code crashes on macOS 15 Sequoia: import Foundation let key = NSAttributedString.Key("org.example.key") let value = Value() let string = NSMutableAttributedString() string.append(NSAttributedString(string: "a", attributes: [:])) string.append(NSAttributedString(string: "b", attributes: [key: value])) string.append(NSAttributedString(string: "c", attributes: [:])) string.enumerateAttribute(key, in: NSRange(location: 0, length: string.length)) { value, range, stop in print(range) } class Value: Equatable, Hashable { static func == (lhs: Value, rhs: Value) -> Bool { return lhs === rhs } func hash(into hasher: inout Hasher) { hasher.combine(ObjectIdentifier(self)) } } The error is EXC_BAD_ACCESS (code=1, address=0x0) I wanted to run it on my external macOS 14 partition to confirm that it didn't crash before updating to macOS 15, but for some reason macOS will just restart and boot again into macOS 15. So I tried with macOS 13, which I was allowed to start for some reason, and I was able to confirm that the code doesn't crash. Is this a known issue, and is there a workaround? Removing the two lines that add the letters a and c, or just declaring class Value without conformance to Equatable, Hashable, interestingly, solves the issue.
4
0
93
1d
UserDefaults.didChangeNotification not firing
Hi, I'm currently working on an app made originally for iOS 15. On it, I add an observer on viewDidLoad function of my ViewController to listen for changes on the UserDefault values for connection settings. NotificationCenter.default.addObserver(self, selector: #selector(settingsChanged), name: UserDefaults.didChangeNotification, object: nil) Said values can only be modified on the app's section from System Settings. Thing is, up to iOS 17, the notification fired as expected, but starting from iOS 18, the notification doesn't seem to be sent by the OS. Is there anything I should change in my observer, or any other technique to listen for the describe event? Thanks in advance.
1
0
106
5d
How does font caching / resources for each app work?
I'm a font developer. In the development process, I will revise a font and overwrite the OTF file that is currently enabled (registered) with macOS. If I then launch an app, it will immediately use the revised version of the font; while apps that are already loaded will continue to use the old version. This suggests that each app is loading new and separate font data, rather than getting it from some existing cache in memory. Yet macOS does have a "font cache" of some sort. Some apps, like TextEdit, seem to only load the fonts that they need to use. However, other apps, like Pages, load every enabled (registered) font on the OS!! (According to the Open Files list in Activity Monitor.) Given that /System/Library/Fonts/ is 625 Mb, and we can't disable any of it, isn't that a lot of data to be repeating? How many fonts is too many fonts? I can't find much documentation about the process.
0
0
94
1w
NSDecimalNumber crash on iOS18 when using decimalNumberByDividingBy
NSDecimalNumber will crash on iOS18 when using decimalNumberByDividingBy in some cases. For example NSDecimalNumber* a= [NSDecimalNumber decimalNumberWithString:@"21000000000"]; NSDecimalNumber* b= [NSDecimalNumber decimalNumberWithString:@"18446744073709551615"]; NSDecimalNumber* c = [a decimalNumberByDividingBy:b]; // this line will crash the crash error is EXC_BREAKPOINT the crash stack is I know some foundation implementation changed on iOS18, But are there some ways to avoid it? It appears on iOS18 only.
1
0
128
1w
JSONEncoder: How to sort keys using "localizedStandardCompare"? (just like how Xcode 16 serialize a xcstrings file)
Hello, I'd like to ask a very fundamental question about JSONEncoder: how to sort keys in a specific order when encoding a dictionary to JSON text? I know there is an option called JSONEncoder.OutputFormatting.sortedKeys, but it sorts the keys only in lexicographic order. I want to sort the keys using a different comparator, such as String.localizedStandardCompare(_:), which achieves the "Finder-like" order. The reason why I ask this question is because I have a localization tool that works with String Catalog (xcstrings file, which is a JSON), but every time my tool serializes an xcstrings file, it always messes up the keys in lexicographic order (I used JSONEncoder + .sortedKeys). Meanwhile, Xcode 16 always serializes the string keys into the "Finder-like" order. As a result, my tool always generates a huge diff when manipulating the xcstrings even when making only a small modification to it. So I am wondering how Xcode 16 implements the String Catalog tool to serialize the JSON in "Finder-like" order. It would be great if JSONEncoder could do that too. Or, maybe I can use another serialization method to implement this behavior?
4
0
221
1w
Has iOS 18 changed the threshold for decoding base64 into ASCII code?
This code fails to decode when running on iOS 18.0 or 18.1 beta device. But succeeds below iOS 18, such as iOS 17.5. Xcode Version 16.0 (16A242d) let base64String = "1ZwoNohdE8Nteis/IXl1rg==" if let decodedData = Data(base64Encoded: base64String, options: .ignoreUnknownCharacters) { if let decodedString = String(data: decodedData, encoding: .ascii) { print("Decoded string: \(decodedString)") } else { print("Failed to decode string using ascii encoding") } } else { print("Failed to decode Base64 string") }
6
0
229
57m
App crash after update to IOS 18
After update to IOS18, my app crashed. following is the exception got from xcode: Trapped uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSFileManager createDirectoryAtURL:withIntermediateDirectories:attributes:error:]: URL is nil' ( 0 CoreFoundation 0x0000000194a79098 47427277-EE15-3C17-AD68-6886B0380B5E + 540824 1 libobjc.A.dylib 0x0000000191d7b2e4 objc_exception_throw + 88 2 Foundation 0x0000000193741f48 12E17A7A-B65F-35EE-82D7-CBC31004E223 + 1154888 3 CFNetwork 0x0000000195eeb2bc FA95B718-E8EB-34BD-90FA-8FB1AFE016D6 + 164540 4 CFNetwork 0x0000000195eeac7c FA95B718-E8EB-34BD-90FA-8FB1AFE016D6 + 162940 5 libdispatch.dylib 0x000000010342a71c _dispatch_client_callout + 20 6 libdispatch.dylib 0x000000010343bf04 _dispatch_lane_barrier_sync_invoke_and_complete + 176 7 CFNetwork 0x0000000195eeaa88 FA95B718-E8EB-34BD-90FA-8FB1AFE016D6 + 162440 8 CFNetwork 0x0000000195ee9b20 FA95B718-E8EB-34BD-90FA-8FB1AFE016D6 + 158496 9 CFNetwork 0x0000000195ee95f4 FA95B718-E8EB-34BD-90FA-8FB1AFE016D6 + 157172 10 CFNetwork 0x0000000195ee907c FA95B718-E8EB-34BD-90FA-8FB1AFE016D6 + 155772 11 CFNetwork 0x0000000195ee34b0 FA95B718-E8EB-34BD-90FA-8FB1AFE016D6 + 132272 12 CFNetwork 0x0000000195f942c4 FA95B718-E8EB-34BD-90FA-8FB1AFE016D6 + 856772 13 CFNetwork 0x0000000195f94214 FA95B718-E8EB-34BD-90FA-8FB1AFE016D6 + 856596 14 CFNetwork 0x0000000195f9330c FA95B718-E8EB-34BD-90FA-8FB1AFE016D6 + 852748 15 libdispatch.dylib 0x0000000103428a30 _dispatch_call_block_and_release + 32 16 libdispatch.dylib 0x000000010342a71c _dispatch_client_callout + 20 17 libdispatch.dylib 0x00000001034325e8 _dispatch_lane_serial_drain + 828 18 libdispatch.dylib 0x0000000103433394 _dispatch_lane_invoke + 460 19 libdispatch.dylib 0x0000000103434b20 _dispatch_workloop_invoke + 2264 20 libdispatch.dylib 0x00000001034405f0 _dispatch_root_queue_drain_deferred_wlh + 328 21 libdispatch.dylib 0x000000010343fc00 _dispatch_workloop_worker_thread + 580 22 libsystem_pthread.dylib 0x000000021bddfc7c _pthread_wqthread + 288 23 libsystem_pthread.dylib 0x000000021bddc488 start_wqthread + 8 ) This app works fine until ios 18 appear. Could you help me? thanks
5
0
571
1w
[iOS18] Crash in `static NSDecimal./ infix(_:_:)`
Crashed: com.apple.main-thread 0 Foundation 0x2bd25c specialized static NSDecimal._integerDivide(dividend:divisor:maxResultLength:) + 1996 1 Foundation 0x2c1c0c specialized NSDecimal._divide(by:roundingMode:) + 2432 2 Foundation 0x372710 static NSDecimal./ infix(_:_:) + 64 Crashed: com.um.positions.fiber.queue 0 Foundation 0x2bdc94 <redacted> + 1996 1 Foundation 0x2c2644 <redacted> + 2432 2 Foundation 0x372804 $sSo9NSDecimala10FoundationE1doiyA2B_ABtFZ + 64 After iOS18, some new crashes appeared, but they never appeared before iOS18. How to avoid such crashes? I checked the API documentation and there is no relevant modification, https://developer.apple.com/documentation/foundation/1409398-nsdecimaldivide However, I parsed iOS_22A5326g/../Foundation.framework/Foundation, and found that this EXC_BREAKPOINT is newly added You can reproduce it with the following code: let a: Decimal = .greatestFiniteMagnitude let b: Decimal = .greatestFiniteMagnitude let c = a / b // if < iOS18, c = 1. if = iOS18, will crashed ;< print(c)
3
1
273
1w
NSMetaData Object IOS
I've been trying to access the NSMetaData information for mb4 objects that I legally downloaded from third party websites without DRM protection. I posted a request in the app forum before and didn't receive any responses from anyone, so it occurred to me to use the example apple code provided on NSMetaData Objects. Steps to reproduce: download the "simpleiclouddocument" example and changed the document extension to Mb4. It seems the query fails because the documents are outside the application directory, so I expanded the search scope to include "NSMetaDataQueryAccessibleExternalDocumentsScope" and the files are still not found. I have the URL of the file that I want the MetaData for. I understand that NSMetaData has an init object that works with a URL but it only works on MacOS and not iOS. I have alternatively tried using LPLinkPresentation and AVMetdataItem but these two alternatives appear to limit the metadata fields I can access and there is no additional object data on how to expand the links to access the other metadata items associated with the file, specifically the Author field as Mb4 files have authors in addition to other audio metadata settings. If there is additional information somewhere on those two classes that identifies how I can access the rest of the metadata fields that would likewise correct my problem.
3
0
142
2w
Crash on launch from all TestFlight builds, but when loading the app from Xcode
We are preparing a launch for iOS 18, and we experienced crashes from iOS 17 devices. If I load the app right from Xcode 16 RC to the iOS 17 device, then it works fine, but if I download it from TestFlight, the nit crashes. The app crashes immediately upon launch due to a missing symbol in the Foundation framework. I'm hoping someone can provide insights or suggestions on how to resolve this. Error Message CopySymbol not found: _$s10Foundation14NSDecimalRoundyySpySo0B0aG_SPyADGSiSo14NSRoundingModeVtF Referenced from: <C1ABDA48-29EE-3674-8554-669220A76F81> /Volumes/VOLUME/*/CamPlan.app/CamPlan Expected in: <D92E19C1-6299-3E94-8614-C505D5ABCCDB> /System/Library/Frameworks/Foundation.framework/Foundation What I've Tried Verified that the app is compiled with the latest Xcode version Checked for any usage of private APIs (none found) Reviewed usage of Foundation framework methods, especially those related to NSDecimalRound Questions What could be causing this symbol to be missing? Are there any known issues with NSDecimalRound or related functions in recent iOS versions? How can I identify which part of my code is trying to use this missing symbol?
6
1
522
1d
Infer error domain and code from localizedDescription
I have been bitten by this repeatedly so I am finally going to ask: Is there a way to infer an error from its localizedDescription only? It sometimes happens that a user reaches out for support with just a localized error message, but no error code or error domain and it is really hard to correctly guess what the non-localized description may have been in order to search for it. For example I know from experience that "Der eingegebene Benutzername oder das Passwort ist ungültig." is the German localization of "The user name or passphrase you entered is not correct." which in turn is errSecAuthFailed (aka. -25293). It would be really helpful to be able to just look this up somewhere...
2
0
210
3w
Range of Network / Multipeer
Since Apple Multipeer framework does not really work without crashes, I implemented my own multipeer with the Network.framework. like let tcpOptions = NWProtocolTCP.Options.createDefault() let parameters = NWParameters(tls: NWProtocolTLS.Options(), tcp: tcpOptions) parameters.setDefaultSettings() let browser = NWBrowser( for: .bonjour( type: config.bonjourServiceType, domain: nil ), using: parameters ) and extension NWParameters { func setDefaultSettings() { self.includePeerToPeer = true self.requiredInterfaceType = .wifi self.preferNoProxies = true } } extension NWProtocolTCP.Options { static func createDefault() -> NWProtocolTCP.Options { let tcpOptions = NWProtocolTCP.Options() tcpOptions.enableKeepalive = true tcpOptions.keepaliveIdle = 10 // 10 seconds keepalive interval tcpOptions.noDelay = true // Disable Nagle's algorithm for low latency return tcpOptions } } it works well up to approx. 30 meter outside with free view. What's the max range for the peer to peer via bonjour? And is there a way to get longer distance than 30 meter?
1
0
241
3w
EXC_BAD_ACCESS (SIGSEGV) crash observed in NSDateFormatter APIs
Hi Team, I am using NSDateFormatter to print date and time in my logger class. // Get current date and time NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; dateFormatter.dateFormat = @"yyyy-MM-dd HH:mm:ss"; NSString *dateTimeString = [dateFormatter stringFromDate:[NSDate date]]; I am using the NSDateFormatter as shown in the above snippet, but I am seeing random crashes with the below stack trace. This crash is random and can't be reproduced consistently. 0 libobjc.A.dylib 0x7ff8051a021d objc_msgSend + 29 1 CoreFoundation 0x7ff8056609ef __CFDateFormatterSetSymbolsArray + 59 2 CoreFoundation 0x7ff80564db87 __ApplyUDateFormatSymbol + 324 3 CoreFoundation 0x7ff80564c854 __ResetUDateFormat + 3064 4 CoreFoundation 0x7ff80564bc30 __CreateCFDateFormatter + 320 5 Foundation 0x7ff8064c2ae3 -[NSDateFormatter _regenerateFormatter] + 323 6 Foundation 0x7ff8064c2858 -[NSDateFormatter stringForObjectValue:] + 297 Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000018 Exception Codes: 0x0000000000000001, 0x0000000000000018 Termination Reason: Namespace SIGNAL, Code 11 Segmentation fault: 11 Terminating Process: exc handler [5372] Can someone please suggest if there is something wrong in the way NSDateFormatter being used? I checked the documentation and found nothing that can be causing this issue. Thanks and Regards
2
0
217
3w
Crash on iOS: UIKitCore -[UIApplication _run] with CFRunLoopRun
Hello everyone, I’m experiencing a crash in my iOS application that’s occurring predominantly on devices running iOS 16.6.0. The crash seems to happen on the main thread during a UI operation, specifically within the UIKitCore framework. Crash Log Summary Thread 0 Crashed: 0 libsystem_kernel.dylib 0xca4 mach_msg2_trap + 8 1 libsystem_kernel.dylib 0x13b74 mach_msg2_internal + 80 2 libsystem_kernel.dylib 0x13e4c mach_msg_overwrite + 540 3 libsystem_kernel.dylib 0x11e8 mach_msg + 24 4 CoreFoundation 0x79024 __CFRunLoopServiceMachPort + 160 5 CoreFoundation 0x7a250 __CFRunLoopRun + 1208 6 CoreFoundation 0x7f3ec CFRunLoopRunSpecific + 612 7 GraphicsServices 0x135c GSEventRunModal + 164 8 UIKitCore 0x39cf58 -[UIApplication _run] + 888 9 UIKitCore 0x39cbbc UIApplicationMain + 340 10 MyApp 0x24050 main + 51 (AppDelegate.swift:51) 11 ??? 0x1d3594dec (Missing) I’ve attached the full crash crashlog.txt and would appreciate any insights or recommendations on how to resolve this issue.
1
0
241
Aug ’24
CF_IS_OBJC crash
Hi all. I've read all the posts related to CF_IS_OBJC, including this one, but since I don't have an Objective-C background and mostly work with Swift and SwiftUI, I'm struggling to fully understand the recommendations or how to address this issue. Could someone explain it to me in simple terms (like I'm 5) and provide a step-by-step guide on what to do? This crash has affected 66 devices over the past month. Crashed: com.apple.main-thread 0 CoreFoundation 0xf878 CF_IS_OBJC + 24 1 CoreFoundation 0x17f58 CFArrayGetCount + 32 2 CoreGraphics 0x322a1c CGPDFTaggedNodeEnumerateChildren + 60 3 CoreGraphics 0x322880 CGPDFTaggedNodeGetBounds + 244 4 PDFKit 0x5524 -[UICGPDFNodeAccessibilityElement isAccessibilityElement] 5 UIAccessibility 0x48518 ___axuiElementForNotificationData_block_invoke + 28 6 UIAccessibility 0x35678 __94-[NSObject(AXPrivCategory) _accessibilityFindFirstAXDescendantPassingTest:byYieldingElements:]_block_invoke_2 + 36 7 UIAccessibility 0x3534c __96-[NSObject(AXPrivCategory) _accessibilityEnumerateAXDescendants:passingTest:byYieldingElements:]_block_invoke + 60 8 UIAccessibility 0x359d0 __57-[NSObject(AXPrivCategory) _accessibilityFindDescendant:]_block_invoke_2 + 60 9 UIAccessibility 0x1ec98 -[NSObject(AXPrivCategory) accessibilityEnumerateContainerElementsWithOptions:usingBlock:] + 548 10 UIAccessibility 0x35858 __57-[NSObject(AXPrivCategory) _accessibilityFindDescendant:]_block_invoke + 176 11 UIAccessibility 0x3539c __96-[NSObject(AXPrivCategory) _accessibilityEnumerateAXDescendants:passingTest:byYieldingElements:]_block_invoke + 140 12 UIAccessibility 0x359d0 __57-[NSObject(AXPrivCategory) _accessibilityFindDescendant:]_block_invoke_2 + 60 13 UIAccessibility 0x1ec98 -[NSObject(AXPrivCategory) accessibilityEnumerateContainerElementsWithOptions:usingBlock:] + 548 14 UIAccessibility 0x35858 __57-[NSObject(AXPrivCategory) _accessibilityFindDescendant:]_block_invoke + 176 15 UIAccessibility 0x3539c __96-[NSObject(AXPrivCategory) _accessibilityEnumerateAXDescendants:passingTest:byYieldingElements:]_block_invoke + 140 16 UIAccessibility 0x359d0 __57-[NSObject(AXPrivCategory) _accessibilityFindDescendant:]_block_invoke_2 + 60 17 UIAccessibility 0x1ec98 -[NSObject(AXPrivCategory) accessibilityEnumerateContainerElementsWithOptions:usingBlock:] + 548 18 UIAccessibility 0x35858 __57-[NSObject(AXPrivCategory) _accessibilityFindDescendant:]_block_invoke + 176 19 UIAccessibility 0x3539c __96-[NSObject(AXPrivCategory) _accessibilityEnumerateAXDescendants:passingTest:byYieldingElements:]_block_invoke + 140 20 UIAccessibility 0x359d0 __57-[NSObject(AXPrivCategory) _accessibilityFindDescendant:]_block_invoke_2 + 60 21 UIAccessibility 0x1ec98 -[NSObject(AXPrivCategory) accessibilityEnumerateContainerElementsWithOptions:usingBlock:] + 548 22 UIAccessibility 0x35858 __57-[NSObject(AXPrivCategory) _accessibilityFindDescendant:]_block_invoke + 176 23 UIAccessibility 0x3539c __96-[NSObject(AXPrivCategory) _accessibilityEnumerateAXDescendants:passingTest:byYieldingElements:]_block_invoke + 140 24 UIAccessibility 0x35918 __57-[NSObject(AXPrivCategory) _accessibilityFindDescendant:]_block_invoke + 368 25 UIAccessibility 0x3539c __96-[NSObject(AXPrivCategory) _accessibilityEnumerateAXDescendants:passingTest:byYieldingElements:]_block_invoke + 140 26 UIAccessibility 0x35294 -[NSObject _accessibilityEnumerateAXDescendants:passingTest:byYieldingElements:] + 244 27 UIAccessibility 0x355d0 -[NSObject _accessibilityFindFirstAXDescendantPassingTest:byYieldingElements:] + 272 28 UIAccessibility 0x35788 -[NSObject(AXPrivCategory) _accessibilityFindDescendant:] + 100 29 UIAccessibility 0x48280 _axuiElementForNotificationData + 276 30 UIAccessibility 0x347c _massageAssociatedElementBeforePost + 36 31 UIAccessibility 0x2648 _UIAXBroadcastMainThread + 292 32 libdispatch.dylib 0x213c _dispatch_call_block_and_release + 32 33 libdispatch.dylib 0x3dd4 _dispatch_client_callout + 20 34 libdispatch.dylib 0x125a4 _dispatch_main_queue_drain + 988 35 libdispatch.dylib 0x121b8 _dispatch_main_queue_callback_4CF + 44 36 CoreFoundation 0x56710 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 37 CoreFoundation 0x53914 __CFRunLoopRun + 1996 38 CoreFoundation 0x52cd8 CFRunLoopRunSpecific + 608 39 GraphicsServices 0x11a8 GSEventRunModal + 164 40 UIKitCore 0x40a90c -[UIApplication _run] + 888 41 UIKitCore 0x4be9d0 UIApplicationMain + 340 42 UIKitCore 0x638384 keypath_get_selector_hoverStyle + 11024 43 Wisconsin State Journal 0x3b4ae8 main + 4299246312 (AppDelegate.swift:4299246312) 44 ??? 0x1b7239e4c (Missing) com.apple.uikit.eventfetch-thread 0 libsystem_kernel.dylib 0x1808 mach_msg2_trap + 8 1 libsystem_kernel.dylib 0x5008 mach_msg2_internal + 80 2 libsystem_kernel.dylib 0x4f20 mach_msg_overwrite + 436 3 libsystem_kernel.dylib 0x4d60 mach_msg + 24 4 CoreFoundation 0x53f5c __CFRunLoopServiceMachPort + 160 5 CoreFoundation 0x53600 __CFRunLoopRun + 1208 6 CoreFoundation 0x52cd8 CFRunLoopRunSpecific + 608 7 Foundation 0xc7e4c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212 8 Foundation 0xc7c9c -[NSRunLoop(NSRunLoop) runUntilDate:] + 64 9 UIKitCore 0x41e640 -[UIEventFetcher threadMain] + 420 10 Foundation 0xde718 __NSThread__start__ + 732 11 libsystem_pthread.dylib 0x606c _pthread_start + 136 12 libsystem_pthread.dylib 0x10d8 thread_start + 8 com.google.firebase.crashlytics.MachExceptionServer 0 Wisconsin State Journal 0x83b668 FIRCLSProcessRecordAllThreads + 392 (FIRCLSProcess.c:392) 1 Wisconsin State Journal 0x83ba48 FIRCLSProcessRecordAllThreads + 423 (FIRCLSProcess.c:423) 2 Wisconsin State Journal 0x849c5c FIRCLSHandler + 34 (FIRCLSHandler.m:34) 3 Wisconsin State Journal 0x84a460 FIRCLSMachExceptionServer + 521 (FIRCLSMachException.c:521) 4 libsystem_pthread.dylib 0x606c _pthread_start + 136 5 libsystem_pthread.dylib 0x10d8 thread_start + 8 Thread 0 libsystem_kernel.dylib 0x1808 mach_msg2_trap + 8 1 libsystem_kernel.dylib 0x5008 mach_msg2_internal + 80 ...
1
0
231
Aug ’24
DateFormatter not working, If I change the TimeZone in iPhone settings
DateFormatter parses the date correctly when using the default timezone in iPhone settings. However, if I change to any custom TimeZone, DateFormatter returns nil. Here is the code snippet extension String{ func toDate() -&gt; Date?{ let dateFormatter = DateFormatter() dateFormatter.dateFormat = "dd-MMM-yyyy hh:mm a" let date = dateFormatter.date(from:self) return date ?? nil } } If I use the default time zone settings in iPhone Settings, it works. However, if I change the time zone to a custom one and switch to a 24-hour format, DateFormatter returns nil. Sample screenshot attached for the time zone settings.
1
0
223
Aug ’24
Array<NSNumber> not working for EKRecurringRule in EventKit
I am having an issue here with the NSNumber Type using with SwiftUI and I am not sure what I am doing wrong here? @State private var recurringMonthsTest: NSNumber = 1` let rule = EKRecurrenceRule( recurrenceWith: recurringOn, interval: recurringInterval, daysOfTheWeek: [EKRecurrenceDayOfWeek.init(EKWeekday.monday)], daysOfTheMonth: [], monthsOfTheYear: [recurringMonthsTest], weeksOfTheYear: [], daysOfTheYear: [], setPositions: nil, end: EKRecurrenceEnd.init(occurrenceCount: 8)) } Here is some basic Code to explain the issue, if you look at the above code it works well, I can also put 2 or more NSNumber single values inside the rule. But if I start to use the Array as below let recurringMonthsTest2: Array<NSNumber> = [recurringMonthsTest, recurringMonthsTest1] let rule = EKRecurrenceRule( recurrenceWith: recurringOn, interval: recurringInterval, daysOfTheWeek: [EKRecurrenceDayOfWeek.init(EKWeekday.monday)], daysOfTheMonth: [], monthsOfTheYear: [recurringMonthsTest2], weeksOfTheYear: [], daysOfTheYear: [], setPositions: nil, end: EKRecurrenceEnd.init(occurrenceCount: 8)) } It doesn't compile and I get the below error which I don't understand. `Cannot convert value of type 'Array' to expected element type 'Array.ArrayLiteralElement' (aka 'NSNumber') As I understand both are of the same value but why they don't compile? I tried already several versions like [NSNumber] = [] but everything is failing... What am I doing wrong here, can anyone help?
1
0
253
Aug ’24
iOS 18 beta 5 NSAttributedString Crash
There have been hundreds of the same crashes occurring every day recently. The crash stack information I have collected is as follows: AppStoreTools: 15F31e AppVariant: 1:iPhone15,4:17 Code Type: ARM-64 (Native) Role: Foreground Parent Process: launchd [1] Coalition: com.***.***.xxxx [1125] Date/Time: 2024-08-12 06:28:47.8121 +0800 Launch Time: 2024-08-12 06:24:53.4931 +0800 OS Version: iPhone OS 18.0 (22A5326f) Release Type: Beta Baseband Version: 2.16.02 Report Version: 104 Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: SIGNAL 6 Abort trap: 6 Terminating Process: xxxx [1439] Triggered by Thread: 0 Last Exception Backtrace: 0 CoreFoundation 0x18f65c08c __exceptionPreprocess + 164 (NSException.m:249) 1 libobjc.A.dylib 0x18c9632e4 objc_exception_throw + 88 (objc-exception.mm:356) 2 Foundation 0x18e2424cc -[NSRLEArray objectAtIndex:effectiveRange:] + 172 (NSAttributedString.m:1408) 3 WebKit 0x1a59d87a0 __70-[WKContentView(WKInteraction) setAttributedMarkedText:selectedRange:]_block_invoke + 156 (WKContentViewInteraction.mm:6305) 4 WebKit 0x1a59d7fec -[WKContentView(WKInteraction) setAttributedMarkedText:selectedRange:] + 136 (WKContentViewInteraction.mm:6297) 5 UIKitCore 0x192db41e0 -[UIResponder(UITextInput_Internal) _setAttributedMarkedText:selectedRange:] + 120 (UITextInput_Internal.m:1735) 6 UIKitCore 0x192a53518 -[UIKBInputDelegateManager setAttributedMarkedText:selectedRange:] + 152 (UIKBInputDelegateManager.m:0) 7 UIKitCore 0x192741050 -[_UIKeyboardStateManager _setAttributedMarkedText:selectedRange:inputString:lastInputString:searchString:compareAttributes:] + 696 (_UIKeyboardStateManager.m:7217) 8 UIKitCore 0x1927407e8 -[_UIKeyboardStateManager setMarkedText:selectedRange:inputString:lastInputString:searchString:candidateOffset:liveConversionSegments:highlighSegmentIndex:] + 692 (_UIKeyboardStateManager.m:7118) 9 UIKitCore 0x192760e38 -[_UIKeyboardStateManager assertIntermediateText:] + 200 (_UIKeyboardStateManager.m:15075) 10 UIKitCore 0x1927440c4 -[_UIKeyboardStateManager syncKeyboardToConfiguration:] + 144 (_UIKeyboardStateManager.m:7934) 11 UIKitCore 0x192745040 __64-[_UIKeyboardStateManager handleKeyboardInput:executionContext:]_block_invoke_2 + 988 (_UIKeyboardStateManager.m:8101) 12 UIKitCore 0x192259834 -[UIKeyboardTaskEntry execute:] + 208 (UIKeyboardTaskQueue.m:869) 13 UIKitCore 0x1922596c8 -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 324 (UIKeyboardTaskQueue.m:447) 14 Foundation 0x18e2b783c __NSThreadPerformPerform + 264 (NSThread.m:1084) 15 CoreFoundation 0x18f62f088 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 28 (CFRunLoop.c:1950) 16 CoreFoundation 0x18f62f01c __CFRunLoopDoSource0 + 176 (CFRunLoop.c:1994) 17 CoreFoundation 0x18f62cb08 __CFRunLoopDoSources0 + 244 (CFRunLoop.c:2031) 18 CoreFoundation 0x18f62bd04 __CFRunLoopRun + 840 (CFRunLoop.c:2949) 19 CoreFoundation 0x18f62b5b8 CFRunLoopRunSpecific + 572 (CFRunLoop.c:3414) 20 GraphicsServices 0x1db3331c4 GSEventRunModal + 164 (GSEvent.c:2196) 21 UIKitCore 0x19218ada0 -[UIApplication _run] + 816 (UIApplication.m:3789) 22 UIKitCore 0x19223917c UIApplicationMain + 340 (UIApplication.m:5439) 23 xxxxx 0x102c1d7b4 main + 84 (main.m:34) 24 dyld 0x1b5120d34 start + 2724 (dyldMain.cpp:1334) Thread 0 name: Thread 0 Crashed: 0 libsystem_kernel.dylib 0x00000001df6be254 __pthread_kill + 8 (:-1) 1 libsystem_pthread.dylib 0x0000000216999ef8 pthread_kill + 268 (pthread.c:1721) 2 libsystem_c.dylib 0x0000000197367ad8 abort + 128 (abort.c:122) 3 libc++abi.dylib 0x00000002168bd5b8 abort_message + 132 (abort_message.cpp:78) 4 libc++abi.dylib 0x00000002168abbac demangling_terminate_handler() + 348 (cxa_default_handlers.cpp:77) 5 libobjc.A.dylib 0x000000018c97ee04 _objc_terminate() + 156 (objc-exception.mm:496) 6 qihooloan_ios 0x000000010397a790 CPPExceptionTerminate() + 504 7 libc++abi.dylib 0x00000002168bc87c std::__terminate(void (*)()) + 16 (cxa_handlers.cpp:59) 8 libc++abi.dylib 0x00000002168c00ac __cxa_rethrow + 204 (cxa_exception.cpp:648) 9 libobjc.A.dylib 0x000000018c97a650 objc_exception_rethrow + 44 (objc-exception.mm:399) 10 CoreFoundation 0x000000018f62b67c CFRunLoopRunSpecific + 768 (CFRunLoop.c:3430) 11 GraphicsServices 0x00000001db3331c4 GSEventRunModal + 164 (GSEvent.c:2196) 12 UIKitCore 0x000000019218ada0 -[UIApplication _run] + 816 (UIApplication.m:3789) 13 UIKitCore 0x000000019223917c UIApplicationMain + 340 (UIApplication.m:5439) 14 xxxxx 0x0000000102c1d7b4 main + 84 (main.m:34) 15 dyld 0x00000001b5120d34 start + 2724 (dyldMain.cpp:1334)
4
1
772
Aug ’24
Date.FormatStyle.Symbol.Hour defaultDigits shows leading zero if amPM is set to .omitted
I'm trying to format a date to show the current time with the least amount of digits as possible. Using Date.FormatStyle and adding .hour() is the closest I can get. See the code below ↓ var formatStyle = Date.FormatStyle() var hourMinute: Date.FormatStyle{ formatStyle .hour() .minute() } // Output 3:15 PM var hourMinuteDefaultDigits: Date.FormatStyle{ formatStyle .hour(.defaultDigits(amPM: .omitted)) .minute() } // Output 03:15 My goal is to output 3:15 without the amPm but that doesn't seem possible using Date.FormatStyle. Based on the documentation this is the function signature func hour(_ format: Date.FormatStyle.Symbol.Hour = .defaultDigits(amPM: .abbreviated)) -> Date.FormatStyle // Output 3:15 PM For some reason if I put .omitted for the amPM then defaultDigits and twoDigits return the same 2 digits for the hour
1
0
236
Aug ’24