Post

Replies

Boosts

Views

Activity

Is this self-initializing variable initialized at app launch, or initialized when it is first called upon by an executing code?
What is this type of variable (specifically constant) declaration called that initializes itself with a "stored procedure" with code within curly braces followed by an empty set of parentheses? I don't know what key words to search for. let object: NSObject = {   let nestedObject = NSObject()   return nestedObject }() I want to know if that variable gets initialized when it's needed the first time if I declare it globally in a swift file outside any other scope, or if it is initialized when the iOS app starts up before the variable is even called. I thought the code within the curly braces runs when the iOS app launches, thus initializing the value of the variable, but I got an run time error while debugging my Xcode project when such a variable is called for the first time. I got a runtime error that says: EXC_BREAKPOINT (code=1, subcode=0x...) I also was told at one time in a question I posted on stackoverflow that the code runs only once.
1
0
403
Jul ’22
Which Xcode files can I delete on macOS Monterey?
Which build caches and unused SDKs can I delete to free up storage on my Mac Pro with the latest macOS Monterey that I just updated? The all fall under the heading "Xcode Project Build Files". I see some that are considered "Xcode Project Build Files" and some "iOS Device Support" and some that are considered "BridgeOS Device Support". They all have the Xcode icon. I explain in detail below how I get to this screen. Basically it's in the System Information app. I'm not sure what is safe to delete. I have to free up space to update my Xcode on my Mac Pro. When I look at the screen that shows when I got to the Apple Logo on the very top left-hand corner of the menu, then go to About this Mac, then the Storage Tab and then click on the button that says "Manage...", then click on the button that says "Review Files"... When I click on "Developer" on the left tab, I see some rather large files. At the top it says, "Remove project build caches and unused SDKs to free storage space."
1
0
2k
Feb ’23
Where do I find documentation for codes for exception types?
I found this article at Apple's Developer Documentation: Understanding the Exception Types in a Crash Report Anyone know where I can find specific documentation for the codes that go with each exception type? I got a run time error during a debug run of my Xcode project for iOS at a line of code where I initialize a custom struct. I want to look up what that "2" represents. Thread 3: EXC_BAD_ACCESS (code=2, address=0x16dbc7ff0) I think I found documentation at one time for those codes at another source outside of Apple. It seems there are codes that are used by hardware manufacturers for "architectures" such as "arm64" and "armv7". I see those in Xcode project build settings. Do I really need to know what each code as given in the error message represent? I found this documentation on Apple's Exception Handling Framework in a search with Google: Exception Handling. I don't see what I need. This framework seems to be more than I need at this time.
1
0
1.6k
Aug ’22
Can I add a CKDatabaseOperation to the queue belonging to a CKContainer object using CKContainer.add(_:)?
Can I add a CKDatabaseOperation to the queue belonging to a CKContainer object using CKContainer.add(_:)? The CKContainer.add(_:) method takes a CKOperation argument, so it will take a subclass of CKOperation as far as I can tell. I can't find any documentation on this. What I'm trying to figure out is which queue should I add a CKFetchRecordsOperation object to? Should I use CKDatabase.add(:), or CKContainer.add(:)? let fetchRecordsOperation = CKFetchRecordsOperation.fetchCurrentUserRecordOperation() I need the CKRecord for the current user for the entire CKContainer, or for the privateCloudDatabase and the sharedCloudDatabase to be specific. If I pass the CKFetchRecordsOperation object to the queue for CKDatabase, would that not return the current CKRecord for the current user for that CKDatabase only? I suspect that if there is a separate CKRecord representing the current user in each database in a container, that they would each hold identical values, even identical recordName fields. Is that the case?
1
0
568
Aug ’22
How does let statement work?
If I have a class property let appDelegate: AppDelegate? = UIApplication.shared.delegate as? AppDelegate Each time appDelegate is accessed, would it return the value at the time it is accessed, or would it return the value the first time it was accessed? I'm trying to understand whether the property above works the same way as let appDelegate: AppDelegate? = { return UIApplication.shared.delegate as? AppDelegate }() The second declaration of the appDelegate property runs the closure the first time the property is accessed and never again. Later references to appDelegate returns the value that was returned the first time the property was accessed.
1
0
505
Aug ’22
what assert statement does and what it does in CloudKitShare sample project?
What does the following line do in the code snippet from CloudKitShare Apple sample Xcode project that I show after that?   assert(zoneID == self.zone.zoneID) // Update the server change token. // operation.recordZoneChangeTokensUpdatedBlock = { (zoneID, serverChangeToken, _) in   assert(zoneID == self.zone.zoneID)   self.setServerChangeToken(newToken: serverChangeToken) } The documentation for the assert statement says that when the project build is -0none and also in Playground, the code terminates completely, and not just exit from the current code, do I understand that correctly? The documentation seems to assume I understand C-style programming.
1
0
946
Sep ’22
What does DispatchQueue.AutoreleaseFrequency.workItem mean?
The documentation for DispatchQueue.AutoreleaseFrequency.workItem says , "The queue configures an autorelease pool before the execution of a block, and releases the objects in that pool after the block finishes executing." Does this mean that the dispatch queue releases each work item or each code in ()->Void after each one finishes executing? When it says, "releases the objects in that pool er the block finishes executing", it makes it sound like there is only one block executing and then the entire pool is released. I'm making sure I verify that I understand this correctly.
1
0
1k
Sep ’22
How do I create a perpetual "wizard" in iOS that allows the user to see the same options over and over until the user selects the option to end the wizard?
What is the most effective approach to to creating a type of "wizard" interface that takes the user through a process step-by-step, and allows the user to take the steps in any order as he goes along? For instance, the user could start out by selecting from three options: select contacts, select addresses, or selecting a message to send. When he selects one of those options, say select contacts, he sees the interface to allow him to perform that selection, and he sees the other two options to select at any time, which would be select addresses and select message. Say he then selects the option to select a message, he then sees an interface to selecta message and he also sees the other two options. And this continues indefinitely until he selects to send the message. I think the usual view controllers and segues would work for this. Would I need only one subclass of UINavigationController and three subclasses of UIViewControllers? Could this lead to any problems? Is it possible to do this with view controllers and segues? Is there a better way? I do use Swift, but this question doesn't require that I use only Swift, as you can see.
1
0
1k
Sep ’22
Why is code not stopping at breakpoints in playground in swift file in Sources folder?
I am using Playground, and I am able to set breakpoints in a file in the Source folder, but code execution doesn't stop at the breakpoints. I know the code runs to those points, because there are print statements that print into the debug area that are placed between those breakpoints. What should I do? Is there a setting that would fix this?
1
0
699
Oct ’22
How do I use lldb with Playground?
I'm getting a runtime error in Playground that tells me to run an lldb command. I am not able to type anything in the debug area of Playground as I can in Xcode. How do I use lldb with Playground. Specifically, the error I'm getting is: error: Execution was interrupted, reason: shared-library-event. The process has been left at the point where it was interrupted, use "thread return "-x"" to return to the state before expression evaluation. I'm able to see some of the "stack trace", I think is what it is, when I click on the icon of an eye on the right side of the code editor in Playground, but it only shows a small portion it.
1
0
1.3k
Oct ’22
Is CKDatabase.save(_:completionHandler) really run synchronously?
CKDatabase save(_:completionHandler:) has a box that says the following below. Yet when I run the method, the completionHandler runs after the print statement after the call to the save method. I noticed the declaration of the method to be run synchronously has an escaping completionHandler. If the method is run synchronously, doesn't using an escaping completionHandler defeat the purpose of executing the method synchronously, or is the documentation wrong and the method is actually run asynchronously both ways? Concurrency Note You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: func save(_ record: CKRecord) async throws -> CKRecord For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously. Here is my essential code with the nonessentials taken out: print("*** 1 before self.privateCloudKitDatabase.save(record)") self.privateCloudKitDatabase.save(record) {       recordReturned, errorReturned in       print("*** 2 closure self.privateCloudKitDatabase.save(record)")     } print("*** 3 after self.privateCloudKitDatabase.save(record)") Here's the debug window: *** 1 before self.privateCloudKitDatabase.save(record) *** 3 after self.privateCloudKitDatabase.save(record) . . . (other print statements) *** 2 closure self.privateCloudKitDatabase.save(record)
1
0
774
Oct ’22