Post

Replies

Boosts

Views

Activity

Accessing Interface Builder GUI Controls Anywhere in the App
I used the Interface Builder to place a Switch object in a view. I ctrl dragged it into the Assistant to make its handler a method of the class the view's is in, which is itself a subclass of "UITableViewController". A dialog box appear into which I entered the function name, and select the the option to have the sender as an argument. The result is function of the form: @IBAction func switchStateChange(_ sender: UISwitch) { } Now I need to query this Switch's On/Off state from elsewhere in the program, and if necessary change its state. It is not a good solution to save the sender parameter to a global variable because then it would require the user to change this switch's state before that global variable is set. What is needed is to identify, and lookup, this switch object to access it from anywhere in the application. How is this done?
1
0
746
Jun ’23
Can't Create Storyboard Outlet
I am not able drag a reference object from a Storyboard screen to code in the Assistant. The expected blue line appears as the screenshot shows, but no code is created in the Assistant. This reference object is not in the Launch Screen. When the the screen this object is in is highlighted, the correct file opens in the Assistant. Dragging this object from the "Content View" folder also does not work, even though the blue line also appears. I was recently able to do this. Something changed. What might have changed?
1
0
1k
Jul ’23
Using DispatchQueue
I am attempting to follow this example of how to create a camera app: https://www.appcoda.com/avfoundation-swift-guide/ It describes a sequence of 4 steps, and these steps are embodied in four functions: func prepare(completionHandler: @escaping (Error?) -> Void) { func createCaptureSession() { } func configureCaptureDevices() throws { } func configureDeviceInputs() throws { } func configurePhotoOutput() throws { } DispatchQueue(label: "prepare").async { do { createCaptureSession() try configureCaptureDevices() try configureDeviceInputs() try configurePhotoOutput() } catch { DispatchQueue.main.async { completionHandler(error) } return } DispatchQueue.main.async { completionHandler(nil) } } } What is confusing me is that it appears these four steps need to be executed sequentially, but in the Dispatch Queue they are executed simultaneously because .async is used. For example farther down that webpage the functions createCaptureSession(), and configureCaptureDevices(), and the others, are defined. In createCaptureSession() the member variables self.frontCamera, and self.rearCamera, are given values which are used in configureCaptureDevices(). So configureCaptureDevices() depends on createCaptureSession() having been already executed, something that it appears cannot be depended upon if both functions are executing simultaneously in separate threads. What then is the benefit of using DispatchQueue()? How is it assured the above example dependencies are met? What is the label parameter of the DispatchQueue()'s initializer used for?
1
0
858
Jul ’23
"Editing Did End" event is not calling its event handler
I have a UITextField object on a storyboard's scene. Its "Editing Did End" event is connected to the view controller's "actIPhoneName()" event handler method as shown in this screenshot. I configured the keyboard to show its "Done" key. I expected that when this Done button is touched, that the keyboard would disappear, and the actIPhoneName() method would be called. But neither of these happen, nor does anything else. The UITextField object remains in edit mode. The breakpoint is never reached. What must I do to make the Done keyboard key work to make the UITextField object lose its First Responder status, and call its "Editing Did End" event handler method?
1
0
848
Jul ’23
Taking Lossless Picture
I am following these directions to code picture taking: https://www.appcoda.com/avfoundation-swift-guide/ These directions are for taking jpeg shots. But what is needed is to output to a lossless format such as DNG, PNG, or BMP. How would those instructions be modified to output pictures in a lossless format? Is there a tutorial similar to the one linked to above that explains how to do lossless formats?
1
0
846
Jul ’23
PHAssetChangeRequest.creationRequestForAsset() Crashes
There is a crash on the closing brace of the photo capture completion handler where commented below. // Initiate image capture: cameraController.captureImage(){ ( image: UIImage?, error: Error? ) in // This closure is the completion handler, it is called when // the picture taking is completed. print( "camera completion handler called." ) guard let image = image else { print(error ?? "Image capture error") return } try? PHPhotoLibrary.shared().performChangesAndWait { PHAssetChangeRequest.creationRequestForAsset(from: image) } // crash here } When step through pauses on that closing brace, and the next step is taken, there is a crash. Once crashed what I see next is assembly code as shown in the below disassembly: libsystem_kernel.dylib`: 0x1e7d4a39c <+0>: mov x16, #0x209 0x1e7d4a3a0 <+4>: svc #0x80 -> 0x1e7d4a3a4 <+8>: b.lo 0x1e7d4a3c4 ; <+40> Thread 11: signal SIGABRT 0x1e7d4a3a8 <+12>: pacibsp 0x1e7d4a3ac <+16>: stp x29, x30, [sp, #-0x10]! 0x1e7d4a3b0 <+20>: mov x29, sp 0x1e7d4a3b4 <+24>: bl 0x1e7d3d984 ; cerror_nocancel 0x1e7d4a3b8 <+28>: mov sp, x29 0x1e7d4a3bc <+32>: ldp x29, x30, [sp], #0x10 0x1e7d4a3c0 <+36>: retab 0x1e7d4a3c4 <+40>: ret Obviously I have screwed up picture taking somewhere. I would much appreciate suggestions on what diagnostics will lead to the resolution of this problem. I can make the entire picture taking code available on request as an attachment. It is too lengthy to post here.
1
0
867
Jul ’23
Can the permission dialog to access the photo library be bypassed?
This handler in my photo app: cameraController.captureImage(){ ( image: UIImage?, error: Error? ) in // This closure is the completion handler, it is called when the picture taking is completed. if let error = error { print( "camera completion handler called with error: " + error.localizedDescription ) }else{ print( "camera completion handler called." ) } // If no image was captured return here: guard let image = image else { print(error ?? "Image capture error") return } var phpPhotoLib = PHPhotoLibrary.shared() if( phpPhotoLib.unavailabilityReason.debugDescription != "nil" ){ print( "phpPhotoLib.unavailabilityReason.debugDescription = " + phpPhotoLib.unavailabilityReason.debugDescription ) }else{ // There will be a crash right here unless the key "Privacy - Photo Library Usage Description" exists in this app's .plist file try? phpPhotoLib.performChangesAndWait{ PHAssetChangeRequest.creationRequestForAsset(from: image) } } } asks the user for permission to store the captured photo data in the library. It does this once. It does not ask on subsequent photo captures. Is there a way for app to bypass this user permission request dialog, or at least present it to the user in advance of triggering a photo capture when the app first runs? In this situation the camera is being used to capture science data in a laboratory setting. The scientist using this app already expects, and needs, the photo to be stored. The redundant permission request dialog makes the data collection cumbersome, and inconvenient, due to the extra effort required to reach the camera where it is located.
1
0
764
Jul ’23
How to look up Photo Pixel Formate Types?
I listed the AVCapturePhotoSettings.availablePhotoPixelFormatTypes array in my iPhone 14 during a running photo session and I got these type numbers: 875704422 875704438 1111970369 I have no idea what these numbers mean. How can I use these numbers to look up a human readable string that can tell me what these types are in a way I am familiar with, such as jpeg, tiff, png, bmp, dng, etc, so I know which of these numbers to choose when I instantiate the class: AVCaptureSession?
1
0
1.7k
Jul ’23
photoOutput() called with its error parameter set
I followed the directions to capture, and store uncompressed (raw), image files at: https://developer.apple.com/documentation/avfoundation/photo_capture/capturing_photos_in_raw_and_apple_proraw_formats I excluded the thumbnails because they are not needed. When picture taking is attempted the completion handling callback method: RAWCaptureDelegate.photoOutput( _ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) is called as expected, but called with its "error" parameter set to the value: Error Domain=AVFoundationErrorDomain Code=-11803 "Cannot Record" UserInfo={AVErrorRecordingFailureDomainKey=3, NSLocalizedDescription=Cannot Record, NSLocalizedRecoverySuggestion=Try recording again.} I do not know what to do about this error. The error message recommends trying again, but the error repeats every time. Any suggestions on possible causes, or how to proceed to find out what is going wrong, would be much appreciated. The device this is run on is an iPhone 14 pro.
1
0
1k
Jul ’23
Debugging communications between iPhone & Mac
I am developing an app that is to be runnable on both Mac Studio, and iPhone 14. The app instance on the Mac communicates with the app's other instance in the iPhone 14. To debug the Bonjour communications I need to run this source code in the debugger in both the Mac Studio simulator, and at the iPhone, simultaneously. The ideal would be to able to step through source code, and set break points, in each app instance simultaneously. Is that possible? If so how?
1
0
1k
Jul ’23
Recovering Lost Password
The MacStudio has only one account on it, and that is of course an admin account. The password to this account is lost. The MacStudio has an association with my AppleID I log into developer.apple.com with. To recover, this procedure was followed: The recovery mode was entered by holding down the power key for 15 seconds. In the options that appeared the "Forgot all passwords" option was clicked on. I entered the same credentials I log into developer.apple.com with. The credentials were accepted. The shell was launched, and the in the shell the command "resetpasswords" entered. The message: "If you don't know the password for any user on your Mac, you can deactivate your Mac and set new passwords for all users. An internet connection will be required to reactivate your Mac". Beneath this message there was in blue text: "Deactivate Mac". I did not proceed after this because I was not sure what deactivation would mean for the files on the computer. On it there is code written in Swift that needs to be preserved. If the deactivation is done will the files be preserved, and be accessible? Or does a deactivation remove all files?
1
1
255
Feb ’25
Enumerating, and Communicating, with iPhone 14s connected to a MacStudio
I have a powered up, and logged in, iPhone 14 connected to a MacStudio by means of lightning cable. This code snippet is being run in the MacStudio inside the XCode IDE: @Published var iPhones: [IPhone] = [] var test: [EAAccessory] = [] var count = 0; /// Update the iPhones list. func Update(){ test = EAAccessoryManager.shared().connectedAccessories count = test.count iPhones = EAAccessoryManager.shared().connectedAccessories.map{ IPhone( Accessory: $0) } // ToDo: Filter for iPhone accessories only } The variable test is set to a value of 0 in the the Update() method. The iPhone 14 is not showing up in the test array. On this webpage: https://developer.apple.com/documentation/externalaccessory/eaaccessorymanager I see this: Important iPhone and iPad apps running on Macs with Apple silicon never receive connection notifications. In the XCode IDE I have target set to Mac. Since I am running this in a Mac, and I have XCode set to a Mac target, I expected the result would be a Mac app running in a Max, and so I expected the above Important notice would not apply. Is my expectation correct? If not what has gone wrong here? Does a MacStudio receive a connection notification when an iPhone 14 is connected? Can EAAccessory methods be used in a MacStudio to communicate with an iPhone 14?
0
0
381
May ’23
Identifier cannot be registered
On my Mac I made the mistake of reorganizing my development files. I renamed files folders, and application names, and moved some folders around to improve order, and better my ability to navigate the file structure. The result was a corrupted project that I could not fix all the errors on. So I created a new project that has the same name as the old, and copied the files into it. The result in the new after all the old project's files were copied to were these errors of the form: Failed to register bundle identifier The app identifier "com.example.com.Trial-iPhone" cannot be registered to your development team because it is not available. Change your bundle identifier to a unique string to try again. No profiles for 'com.example.com.Trial-iPhone' were found Xcode couldn't find any iOS App Development provisioning profiles matching 'com.IntOpSys.com.Bonjour-Trial-iPhone'. (not the real domain name) So I logged into my developer account at developer.apple.com to delete this certificate, and could not find a way to navigate in my account to where that is done. Is that doable? Where, or How? I worked around the problem by appending a revision letter to the Bundle Identifier, such that it is now: com.example.com.Trial-iPhoneA . I would rather not have to do this when I already have an identifier to use, and also I do not like the idea of accumulating old, and never again used, certificates.
Topic: Code Signing SubTopic: General Tags:
0
0
1.8k
May ’23