Post

Replies

Boosts

Views

Activity

Assignment operator in Swift - What is the rationale behind language design ?
I suspect this point has been discussed in length, but I would like to find some reference to the design logic behind some Swift key aspect : the assignment operator, by value or reference. We know well how = works, depending it deals with reference or value (knowing the consequence of misuse) and the difference between the 2 : class AClass { var val: Int = 0 } struct AStruct { var val : Int = 0 } let aClass = AClass() let bClass = aClass bClass.val += 10 print("aClass.val", aClass.val, "bClass.val", bClass.val) let aStruct = AStruct() var bStruct = aStruct bStruct.val += 10 print("aStruct.val", aStruct.val, "bStruct.val", bStruct.val) Hence my question. Was it ever considered to have 2 operators, one used to assign reference and the other to assign value? Imagine we have : = operator when dealing with references := operator when dealing with content. Then let bClass = aClass would remain unchanged. But var bStruct = aStruct would not be valid anymore, with a compiler warning to replace by var bStruct := aStruct On the other end, we could now write let bClass := aClass to create a new instance and assign another instance content, equivalent to convenience initialiser class AClass { var val: Int = 0 init(with aVar: AClass) { self.val = aVar.val } init() { } } called as let cClass = AClass(with: aClass) But the 2 operators would have made it clear that when using = we copy the reference. When using := we copy content. I do think there is a strong rationale behind the present design choice (side effects I do not see ?), but I would appreciate to better understand which.
2
0
804
Jun ’21
Height of safe area margin in iPhone 12 Pro Max
I have an image to fill the entire screen, even behind the notch. So I set the Top margin to safe area to -44. That works OH on all iPhones… except on iPhone 12 ProMax simulator. Here I get a few pixels uncovered at top. I had to change value to -48 to get everything OK. So question is: has "notch area" which defines safe area increased 4 pixels on iPhone 12 Pro max ? If so, is it a hardware change ?
1
0
4.1k
Jun ’21
Getting back from Splitview
In this app, I have: a VC as entry point (root) which segues (push) to a SplitViewController On iPad, when I get into the splitView, I can get back to the root by dragging down the split view. But on iPhone, this does not work: even though presentation is .automatic, Splitview covers all screen. No way to get back. I tried to create a back button in the detail views… Could not get it. What is the best way to do this ? is there a setup for the initial segue or the views presentation modes to allow pop back ? can I add a back button ? Where, calling what action to return ? I cannot embed splitViewController in nav stack … I would like to have the same solution on both iPhone and iPad…
1
0
669
Jun ’21
Using and expressing "case let" statements
After seveal years with Swift, I still find it hard to use the if case let or while case let, even worse with opotional pattern if case let x?.So, I would like to find an expression to "speak" case let more naturally.Presently, to be sure of what I do, I have to menatlly replace the if case by the full switch statement, with a single case and default ; pretty tedious.I thought of canMatch or canMatchUnwrap … with:So, following would readif case let x = y { // if canMatch x with yif case let x? = someOptional { // if canMatchUnwrap x with someOptionalwhile case let next? = node.next { // while canMatchUnwrap next with node.nextAm I the only one with such problem ? Have you found a better way ?
5
0
7.8k
Jun ’21
Search in Download / more broken ?
In the new version of download > More, there doesn't seem to be a way to filter search efficiently. I searched for instance for MacOS (to see all releases). I get a very long list (200+) references, with a lot of Xcode, but nothing specific to MacOS. If I search for Xcode 11, I get all Xcode references: I added quotes to try and force an exact search, I just get a Java extension… That was not the case in the previous version of the more page. Or do I miss something ?
2
0
639
Jul ’21
Lines numbering in Code Block
The Code Block doesn't number lines anymore. The work around is to ask for Numbered list in addition to Code block. Just applying Code Block: required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) commonInit() } Code Block AND Numbered List (or the other order) 1. required init?(coder aDecoder: NSCoder) { 2. super.init(coder: aDecoder) 3. commonInit() 4. } Is there another way to get numbering directly ?
4
0
939
Aug ’21
Video required for WatchOS app ?
I submitted an iOS app with a watchOS companion app.App has been 'Metadata Rejected':Here is the full message:Guideline 2.1 - Information NeededWe have started the review of your app, but we are not able to continue because we need access to a video that demonstrates the current version of your app in use on a physical watchOS device.Please only include footage in your demo video of your app running on a physical watchOS device, and not on a simulator. It is acceptable to use a screen recorder to capture footage of your app in use.Next StepsTo help us proceed with the review of your app, please provide us with a link to a demo video in the App Review Information section of App Store Connect and reply to this message in Resolution Center.To provide a link to a demo video:- Log in to App Store Connect- Click on "My Apps"- Select your app- Click on the app version on the left side of the screen- Scroll down to "App Review Information"- Provide demo video access details in the "Notes" section- Once you've completed all changes, click the "Save" button at the top of the Version Information page.Please note that in the event that your app may only be reviewed by means of a demo video, you will be required to provide an updated demo video with every resubmission.Since your App Store Connect status is Metadata Rejected, we do NOT require a new binary. To revise the metadata, visit App Store Connect to select your app and revise the desired metadata values. Once you’ve completed all changes, reply to this message in Resolution Center and we will continue the review.I have 3 questions:- Is it a systematic requirement for Watch apps ? I did not see in guidelines ; or is it for some reason specific to my app or to the reviewer ?- How can I record video on the Apple Watch ? Should I film the watch while in operation and post this video ? Or is there a direct way to record the video from the watch to iPhone (using system tools, not third party).- I understand it is not video for publication on appstore, but video for tester. So should I include video in the screen captures section or put it on some web site and give a link to it to the tester ?
7
0
3.8k
Sep ’21
Change in Watch 7 in rounded corners of WKInterfaceLabel or WKInterfaceGroup
When testing in simulator with Xcode 13, I noted a subtle difference in the display of WKInterfaceLabel between Watch series 6 and series 7. WKInterfaceLabel is in a WKInterfaceGroup. On Series 7: the text Fast Driving is clipped with round corner at top and bottom On Series 6, round clipping is much less (noticeable on leading F and D) I could not find what parameter has changed in IB nor how to change this round corner value. Nor why such a change ?
3
0
2k
Nov ’21
SegmentedControl do not work correctly on iPhone 13Mini simulator
UISegmented controls seem not to work correctly in iPhone 13 Mini simulator. When tapping on a segment, control does not react before 30 to 40 s ; then it shows uncomplete redraw: I also noted similar lag in updating display when some label text changes. Configuration: MacOS 11.6.1 Xcode 13RC iOS 15.0 simulator. It works ok on a few other simulators I tested. I created an extremely simple project to reproduce: new project in Xcode 13RC added a segmentedControl at bottom of view, constrained to leading and trailing 0 to the safe area set selected color to red. run on iPhone 13 mini simulator I will test later with Xcode 13.2ß
1
0
919
Nov ’21
UIApplication.openSettingsURLString does not work on iPadOS 15 simulator ?
The following code opens the app settings, including preferred language. func openSettings() { guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else { return } if UIApplication.shared.canOpenURL(settingsUrl) { UIApplication.shared.open(settingsUrl, completionHandler: nil) } } That works well in iOS (14.6 or 15.2), on iPadOS 14.4 ( both device and simulator) But on iPadOS 15.2 simulator, the preferred language setting for the app does not show. I noticed this in 2 different apps.
1
0
1.1k
Dec ’21
Perform action once UIActivityViewController has completed item action
I use UIActivityViewController to airDrop pdfFile (pdfURL) from iPhone to iMac. Works well, file is airDropped. let activityVC = UIActivityViewController(activityItems: [pdfURL], applicationActivities: nil) present(activityVC, animated: true, completion: nil) I want to customise it: limit services to AIrDrop and mail How can I exclude such services as WhatsApp, Notes… ? perform some action once the file has completed airDrop or once cancelled. I tried to implement with completionWithItemsHandler:         activityVC.completionWithItemsHandler = { (activity, success, items, error) in             print("Completed")         } This doesn't work, print is not executed. My ultimate goal is to close the activityVC automatically once action was completed, without need to tap close button. Should I define some content for applicationActivities ?
2
0
953
Jan ’22
repeatCount in UIViewPropertyAnimator
I have a func to flash a view a number of times and execute closure at the end. The following code with UIView.setAnimationRepeatCount works OK: animation occurs the requested number of times and afterEnd closure executes at the end. func flashIt(repeated: Int, cycleTime: Double, delayed: Double = 5.0, afterEnd: (() -> Void)? = nil) { if repeated < 0 { return } let initAlpha = self.alpha UIView.animate(withDuration: cycleTime, delay: delayed, options:[.allowUserInteraction, .curveEaseInOut, .autoreverse, .repeat], animations: { UIView.setAnimationRepeatCount(Float(repeated)) self.alpha = 0.1 // Not 0.0, to allow user interaction }, completion: { (done: Bool) in self.alpha = initAlpha afterEnd?() } ) } To address UIView.setAnimationRepeatCount deprecation, I now try this (inspired by https://stackoverflow.com/questions/47496584/uiviewpropertyanimator-reverse-animation) func flashIt(repeated: Int, cycleTime: Double, delayed: Double = 5.0, afterEnd: (() -> Void)? = nil) { if repeated < 0 { return } let initAlpha = self.alpha let animator = UIViewPropertyAnimator(duration: cycleTime, curve: .linear) { self.alpha = 0.1 } animator.addCompletion { _ in let reverseAnimator = UIViewPropertyAnimator(duration: cycleTime, curve: .linear) { self.alpha = initAlpha } reverseAnimator.addCompletion { [self] _ in flashIt(repeated: repeated-1, cycleTime: cycleTime, delayed: 0) // without delay here } reverseAnimator.startAnimation() if repeated <= 1 { // 1 and not 0, otherwise an extra loop… afterEnd?() // Not called return } } animator.startAnimation(afterDelay: delayed) } The flash works, but afterEnd closure is never called. I've tried to call if repeated <= 1 { // 1 and not 0, otherwise an extra loop… afterEnd?() // Not called return } in other places, to no avail. What do I miss ? Is there a better and simpler way to have a RepeatCount with UIViewPropertyAnimator ?
3
0
1.5k
Jan ’22
New version of forum allows images
We have been waiting for this for many years. And the icon is there, at the right most That's a GREAT plus for the forum.
Replies
1
Boosts
0
Views
789
Activity
May ’21
Assignment operator in Swift - What is the rationale behind language design ?
I suspect this point has been discussed in length, but I would like to find some reference to the design logic behind some Swift key aspect : the assignment operator, by value or reference. We know well how = works, depending it deals with reference or value (knowing the consequence of misuse) and the difference between the 2 : class AClass { var val: Int = 0 } struct AStruct { var val : Int = 0 } let aClass = AClass() let bClass = aClass bClass.val += 10 print("aClass.val", aClass.val, "bClass.val", bClass.val) let aStruct = AStruct() var bStruct = aStruct bStruct.val += 10 print("aStruct.val", aStruct.val, "bStruct.val", bStruct.val) Hence my question. Was it ever considered to have 2 operators, one used to assign reference and the other to assign value? Imagine we have : = operator when dealing with references := operator when dealing with content. Then let bClass = aClass would remain unchanged. But var bStruct = aStruct would not be valid anymore, with a compiler warning to replace by var bStruct := aStruct On the other end, we could now write let bClass := aClass to create a new instance and assign another instance content, equivalent to convenience initialiser class AClass { var val: Int = 0 init(with aVar: AClass) { self.val = aVar.val } init() { } } called as let cClass = AClass(with: aClass) But the 2 operators would have made it clear that when using = we copy the reference. When using := we copy content. I do think there is a strong rationale behind the present design choice (side effects I do not see ?), but I would appreciate to better understand which.
Replies
2
Boosts
0
Views
804
Activity
Jun ’21
Height of safe area margin in iPhone 12 Pro Max
I have an image to fill the entire screen, even behind the notch. So I set the Top margin to safe area to -44. That works OH on all iPhones… except on iPhone 12 ProMax simulator. Here I get a few pixels uncovered at top. I had to change value to -48 to get everything OK. So question is: has "notch area" which defines safe area increased 4 pixels on iPhone 12 Pro max ? If so, is it a hardware change ?
Replies
1
Boosts
0
Views
4.1k
Activity
Jun ’21
Getting back from Splitview
In this app, I have: a VC as entry point (root) which segues (push) to a SplitViewController On iPad, when I get into the splitView, I can get back to the root by dragging down the split view. But on iPhone, this does not work: even though presentation is .automatic, Splitview covers all screen. No way to get back. I tried to create a back button in the detail views… Could not get it. What is the best way to do this ? is there a setup for the initial segue or the views presentation modes to allow pop back ? can I add a back button ? Where, calling what action to return ? I cannot embed splitViewController in nav stack … I would like to have the same solution on both iPhone and iPad…
Replies
1
Boosts
0
Views
669
Activity
Jun ’21
Using and expressing "case let" statements
After seveal years with Swift, I still find it hard to use the if case let or while case let, even worse with opotional pattern if case let x?.So, I would like to find an expression to "speak" case let more naturally.Presently, to be sure of what I do, I have to menatlly replace the if case by the full switch statement, with a single case and default ; pretty tedious.I thought of canMatch or canMatchUnwrap … with:So, following would readif case let x = y { // if canMatch x with yif case let x? = someOptional { // if canMatchUnwrap x with someOptionalwhile case let next? = node.next { // while canMatchUnwrap next with node.nextAm I the only one with such problem ? Have you found a better way ?
Replies
5
Boosts
0
Views
7.8k
Activity
Jun ’21
Search in Download / more broken ?
In the new version of download > More, there doesn't seem to be a way to filter search efficiently. I searched for instance for MacOS (to see all releases). I get a very long list (200+) references, with a lot of Xcode, but nothing specific to MacOS. If I search for Xcode 11, I get all Xcode references: I added quotes to try and force an exact search, I just get a Java extension… That was not the case in the previous version of the more page. Or do I miss something ?
Replies
2
Boosts
0
Views
639
Activity
Jul ’21
Lines numbering in Code Block
The Code Block doesn't number lines anymore. The work around is to ask for Numbered list in addition to Code block. Just applying Code Block: required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) commonInit() } Code Block AND Numbered List (or the other order) 1. required init?(coder aDecoder: NSCoder) { 2. super.init(coder: aDecoder) 3. commonInit() 4. } Is there another way to get numbering directly ?
Replies
4
Boosts
0
Views
939
Activity
Aug ’21
Rearrange pdf Document in Swift in iOS app
How to reorder a pdf document? move page p after page n, or at a given m position. add new page at certain position rotate a page 90° or 180°. I've seen libraries, but I would prefer to redevelop those simple functions directly in an iOS app (Swift). I don't need to edit the document content, just rearrange.
Replies
1
Boosts
0
Views
1.1k
Activity
Aug ’21
No more mail notification from forum
Even though I have selected all the notification options in my profile, I do not receive any mail (since about a week), at least when an answer is marked as correct. I did check they are not in spam. What do I miss ?
Replies
5
Boosts
0
Views
1.5k
Activity
Aug ’21
Video required for WatchOS app ?
I submitted an iOS app with a watchOS companion app.App has been 'Metadata Rejected':Here is the full message:Guideline 2.1 - Information NeededWe have started the review of your app, but we are not able to continue because we need access to a video that demonstrates the current version of your app in use on a physical watchOS device.Please only include footage in your demo video of your app running on a physical watchOS device, and not on a simulator. It is acceptable to use a screen recorder to capture footage of your app in use.Next StepsTo help us proceed with the review of your app, please provide us with a link to a demo video in the App Review Information section of App Store Connect and reply to this message in Resolution Center.To provide a link to a demo video:- Log in to App Store Connect- Click on "My Apps"- Select your app- Click on the app version on the left side of the screen- Scroll down to "App Review Information"- Provide demo video access details in the "Notes" section- Once you've completed all changes, click the "Save" button at the top of the Version Information page.Please note that in the event that your app may only be reviewed by means of a demo video, you will be required to provide an updated demo video with every resubmission.Since your App Store Connect status is Metadata Rejected, we do NOT require a new binary. To revise the metadata, visit App Store Connect to select your app and revise the desired metadata values. Once you’ve completed all changes, reply to this message in Resolution Center and we will continue the review.I have 3 questions:- Is it a systematic requirement for Watch apps ? I did not see in guidelines ; or is it for some reason specific to my app or to the reviewer ?- How can I record video on the Apple Watch ? Should I film the watch while in operation and post this video ? Or is there a direct way to record the video from the watch to iPhone (using system tools, not third party).- I understand it is not video for publication on appstore, but video for tester. So should I include video in the screen captures section or put it on some web site and give a link to it to the tester ?
Replies
7
Boosts
0
Views
3.8k
Activity
Sep ’21
Change in Watch 7 in rounded corners of WKInterfaceLabel or WKInterfaceGroup
When testing in simulator with Xcode 13, I noted a subtle difference in the display of WKInterfaceLabel between Watch series 6 and series 7. WKInterfaceLabel is in a WKInterfaceGroup. On Series 7: the text Fast Driving is clipped with round corner at top and bottom On Series 6, round clipping is much less (noticeable on leading F and D) I could not find what parameter has changed in IB nor how to change this round corner value. Nor why such a change ?
Replies
3
Boosts
0
Views
2k
Activity
Nov ’21
SegmentedControl do not work correctly on iPhone 13Mini simulator
UISegmented controls seem not to work correctly in iPhone 13 Mini simulator. When tapping on a segment, control does not react before 30 to 40 s ; then it shows uncomplete redraw: I also noted similar lag in updating display when some label text changes. Configuration: MacOS 11.6.1 Xcode 13RC iOS 15.0 simulator. It works ok on a few other simulators I tested. I created an extremely simple project to reproduce: new project in Xcode 13RC added a segmentedControl at bottom of view, constrained to leading and trailing 0 to the safe area set selected color to red. run on iPhone 13 mini simulator I will test later with Xcode 13.2ß
Replies
1
Boosts
0
Views
919
Activity
Nov ’21
UIApplication.openSettingsURLString does not work on iPadOS 15 simulator ?
The following code opens the app settings, including preferred language. func openSettings() { guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else { return } if UIApplication.shared.canOpenURL(settingsUrl) { UIApplication.shared.open(settingsUrl, completionHandler: nil) } } That works well in iOS (14.6 or 15.2), on iPadOS 14.4 ( both device and simulator) But on iPadOS 15.2 simulator, the preferred language setting for the app does not show. I noticed this in 2 different apps.
Replies
1
Boosts
0
Views
1.1k
Activity
Dec ’21
Perform action once UIActivityViewController has completed item action
I use UIActivityViewController to airDrop pdfFile (pdfURL) from iPhone to iMac. Works well, file is airDropped. let activityVC = UIActivityViewController(activityItems: [pdfURL], applicationActivities: nil) present(activityVC, animated: true, completion: nil) I want to customise it: limit services to AIrDrop and mail How can I exclude such services as WhatsApp, Notes… ? perform some action once the file has completed airDrop or once cancelled. I tried to implement with completionWithItemsHandler:         activityVC.completionWithItemsHandler = { (activity, success, items, error) in             print("Completed")         } This doesn't work, print is not executed. My ultimate goal is to close the activityVC automatically once action was completed, without need to tap close button. Should I define some content for applicationActivities ?
Replies
2
Boosts
0
Views
953
Activity
Jan ’22
repeatCount in UIViewPropertyAnimator
I have a func to flash a view a number of times and execute closure at the end. The following code with UIView.setAnimationRepeatCount works OK: animation occurs the requested number of times and afterEnd closure executes at the end. func flashIt(repeated: Int, cycleTime: Double, delayed: Double = 5.0, afterEnd: (() -> Void)? = nil) { if repeated < 0 { return } let initAlpha = self.alpha UIView.animate(withDuration: cycleTime, delay: delayed, options:[.allowUserInteraction, .curveEaseInOut, .autoreverse, .repeat], animations: { UIView.setAnimationRepeatCount(Float(repeated)) self.alpha = 0.1 // Not 0.0, to allow user interaction }, completion: { (done: Bool) in self.alpha = initAlpha afterEnd?() } ) } To address UIView.setAnimationRepeatCount deprecation, I now try this (inspired by https://stackoverflow.com/questions/47496584/uiviewpropertyanimator-reverse-animation) func flashIt(repeated: Int, cycleTime: Double, delayed: Double = 5.0, afterEnd: (() -> Void)? = nil) { if repeated < 0 { return } let initAlpha = self.alpha let animator = UIViewPropertyAnimator(duration: cycleTime, curve: .linear) { self.alpha = 0.1 } animator.addCompletion { _ in let reverseAnimator = UIViewPropertyAnimator(duration: cycleTime, curve: .linear) { self.alpha = initAlpha } reverseAnimator.addCompletion { [self] _ in flashIt(repeated: repeated-1, cycleTime: cycleTime, delayed: 0) // without delay here } reverseAnimator.startAnimation() if repeated <= 1 { // 1 and not 0, otherwise an extra loop… afterEnd?() // Not called return } } animator.startAnimation(afterDelay: delayed) } The flash works, but afterEnd closure is never called. I've tried to call if repeated <= 1 { // 1 and not 0, otherwise an extra loop… afterEnd?() // Not called return } in other places, to no avail. What do I miss ? Is there a better and simpler way to have a RepeatCount with UIViewPropertyAnimator ?
Replies
3
Boosts
0
Views
1.5k
Activity
Jan ’22