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 ?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I try to exclude some activities from UIActivity.
It works as expected when exclusion is done directly with the activity, as with:
UIActivity.ActivityType.message,
UIActivity.ActivityType.airDrop
but not when activity is declared with an init as with:
UIActivity.ActivityType(rawValue: "net.whatsapp.WhatsApp.ShareExtension"),
UIActivity.ActivityType(rawValue: "com.ifttt.ifttt.share"),
So, with the following code:
let excludedActivityTypes = [
UIActivity.ActivityType.message,
UIActivity.ActivityType.airDrop,
UIActivity.ActivityType(rawValue: "net.whatsapp.WhatsApp.ShareExtension"),
UIActivity.ActivityType(rawValue: "com.ifttt.ifttt.share")
]
let activityVC = UIActivityViewController(activityItems: [modifiedPdfURL], applicationActivities: nil)
activityVC.excludedActivityTypes = excludedActivityTypes
message and airDrop do not show, but WhatsApp and IFTTT still show.
I have tested with
activityVC.completionWithItemsHandler = { (activity, success, modifiedItems, error) in
print("activity: \(activity), success: \(success), items: \(modifiedItems), error: \(error)")
}
that WhatsApp and IFTTT services are effectively the ones listed here.
When selecting WhatsApp, print above gives:
activity: Optional(__C.UIActivityType(_rawValue: net.whatsapp.WhatsApp.ShareExtension)), success: false, items: nil, error: nil
I get this error in Xcode 14 / iOS 16 on device that I had not with previous versions.
[general] *** -[NSKeyedUnarchiver validateAllowedClass:forKey:] allowed unarchiving safe plist type ''NSNumber' (0x205da88f8) [/System/Library/Frameworks/Foundation.framework]' for key 'NS.objects', even though it was not explicitly included in the client allowed classes set: '{(
"'NSDictionary' (0x205da1178) [/System/Library/Frameworks/CoreFoundation.framework]",
"'NSString' (0x205da8948) [/System/Library/Frameworks/Foundation.framework]"
)}'. This will be disallowed in the future.
The only places where I reference NSDictionary.self or NSString.self or NSNumber.self for allowed classes are:
@objc class MyClass : NSObject, NSSecureCoding {
required init(coder decoder: NSCoder) {
let myObject = decoder.decodeObject(of: [MyClass.self, NSNumber.self, NSArray.self, NSDictionary.self, NSString.self], forKey: myKey) as? [SomeClass] ?? []
}
and in another class
class Util {
// in a class func:
let data = try Data(contentsOf: fileURL)
guard let unarchived = try NSKeyedUnarchiver.unarchivedObject(ofClass: NSDictionary.self, from: data) else { return nil }
I do not understand what NS.objects refers to.
I tried to add NSObject.self in
let myObject = decoder.decodeObject(of: [MyClass.self, NSNumber.self, NSArray.self, NSDictionary.self, NSString.self, NSObject.self], forKey: myKey) as? [SomeClass] ?? []
but that gave even more warnings:
[Foundation] *** -[NSKeyedUnarchiver validateAllowedClass:forKey:]: NSSecureCoding allowed classes list contains [NSObject class], which bypasses security by allowing any Objective-C class to be implicitly decoded. Consider reducing the scope of allowed classes during decoding by listing only the classes you expect to decode, or a more specific base class than NSObject. This will become an error in the future. Allowed class list: {(
"'NSNumber' (0x205da88f8) [/System/Library/Frameworks/Foundation.framework]",
"'NSArray' (0x205da1240) [/System/Library/Frameworks/CoreFoundation.framework]",
"'NSObject' (0x205d8cb98) [/usr/lib]",
"'NSDictionary' (0x205da1178) [/System/Library/Frameworks/CoreFoundation.framework]",
"'MyClass.self' (0x1002f11a0) [/private/var/containers/Bundle/Application/5517240E-FB23-468D-80FA-B7E37D30936A/MyApp.app]",
"'NSString' (0x205da8948) [/System/Library/Frameworks/Foundation.framework]"
Another warning refers to NS.keys:
2022-09-16 16:19:10.911977+0200 MyApp[4439:1970094] [general] *** -[NSKeyedUnarchiver validateAllowedClass:forKey:] allowed unarchiving safe plist type ''NSString' (0x205da8948) [/System/Library/Frameworks/Foundation.framework]' for key 'NS.keys', even though it was not explicitly included in the client allowed classes set: '{(
"'NSDictionary' (0x205da1178) [/System/Library/Frameworks/CoreFoundation.framework]"
)}'. This will be disallowed in the future.
I do not understand what NS.keys refers to.
What additional class types should I add ?
I'm running a simulation (SwiftUI app), which has 100 steps.
I need each step to be executed in order.
A first try was to dispatch with delay to schedule each second:
for step in 0..<100 {
DispatchQueue.main.asyncAfter(deadline: .now() + Double(step) * 1.0) {
// simulation code
}
}
Very poor results as 100 running threads are too much load for the system.
So I split in 2 stages:
for bigStep in 0..<10 {
DispatchQueue.main.asyncAfter(deadline: .now() + Double(bigStep) * 10.0 ) {
for step in 0..<10 {
DispatchQueue.main.asyncAfter(deadline: .now() + Double(step) * 1.0) {
// simulation code
}
}
}
}
It works much better, as now there are a max of 20 threads active (in fact I create more levels to limit to a max of 8 concurrent threads).
It addition, it allows to interrupt the simulation before end.
My questions:
is it the appropriate pattern ?
Would a timer be better ?
Other options ?
I notice that several (most) tags are not accessible now (Nov 2, 19:30 GMT). For instance
https://developer.apple.com/forums/tags/ios
https://developer.apple.com/forums/tags/uikit
https://developer.apple.com/forums/tags/macos
https://developer.apple.com/forums/tags/appkit
https://developer.apple.com/forums/tags/xcode
https://developer.apple.com/forums/tags/interface-builder
all with the same error: The page you’re looking for can’t be found
But others are:
https://developer.apple.com/forums/
https://developer.apple.com/forums/tags/swift
Is it only me ?
Capability to read and write ofd HFS disks on Mac has been removed since a long time.
Capability to simply read was also removed since Catalina I think.
That is surprising and sometimes frustrating. I still use a 90's MacBook for a few tasks and need from time to time to transfer files to newer Mac or read some old files stored on 3.5" disks.
Solution I use is to read the disk on an old Mac with MacOS 10.6 (I'm lucky enough to have kept one) and transfer to USB stick or airdrop…
As there is no USB port on the Macbook of course (and I have no more a working 56k modem to transfer by mail), only option if not 3,5" disk is using PCMCIA port on the MacBook for writing to an SD Card to be read in Mac Sonoma. But reading directly 3.5" disk would be great.
Hence my questions for the forum:
how hard would it be to write such a driver for READING only HFS on Mac Sonoma?
There are some software like FuseHFS. Did anyone experience it ? Did anyone have a look at the source code (said to be open source).
does anyone know why Apple removed such capability (I thought it was a tiny piece of code compared to the GB of present MacOS)?
Thanks for any insights on the matter.
Not a question, but a surprise.
Did I miss something, but apparently there has been no new beta release (16.3) since Release of 16.2 on Dec 11. 2 months without betas is really unusual (in fact, it never happened and usually, next beta n+1 is even released before the final release of version n).
So does that mean 16.3 will be a major update ? Wait and see.
I repeat this older thread, as it does not show on the forum with my added post !https://forums.developer.apple.com/message/298938#298938I answered to KMT answer (I read the referenced thread)---------------Looks like that triggered the name change dialog.Can you just right click on the watch name without that happening? Try it on the phone, on the left so see what I'm looking for.Otherwise, this sounds like what others went thru (routine pairing v o o d o o ) in this SO thread - seen it ? [ filter does not like v o o …]https://stackoverflow.com/questions/30792520/in-xcode-i-see-no-paired-apple-watch-even-though-the-watch-is-paired-and-the-w-------------------------So, my question nowI run in the same problem.I just got the Apple Watch (4, OS 5.1.1) and use XCode 10.1. OSX 10.13.6I can create the app + WatchOS on simulator without problem. But not on device.The watch is paired with iPhone.I connect iPhone with USB=> get the message :The iPhone "iPhone XS" can not be used because it requires iTunes 12.9 or later. Do you want to download the latest version of iTunes now?I ignore the message (as I think iTunes 12.9 requires Mojave, isn't it ?). Could it be the problem ???In XCode, I select the scheme iPhone Xs of XXX + Apple Watch of XXXI run, it compiles OK, but at the end says:"Finished running myApp on Apple Watch of XXX" in the XCode barPlus alert:App installation failedThe host is not paired with the device.I have checked in XCode Devices:- on the left, I see iPhoneXS of XXX- but not the Watch- On the right of Devices window, I see the PAIRED WATCHES:Apple Watch of XXXI also checked that Apple Watch is listed with an UDID in the Devices listThe scheme was in Debug mode.So, I changed to release mode, and get the message in Scheme that paired devices not available for debug.So, Compile again, but then get message :Could not launch 'Autonomie' on iPhone XS XXXThere was an error preparing Apple Watch de XXX for development.Try reattaching the device to which Apple Watch de XXX is paired. The device rejected the pairing attempt.So I unpaired the device.ReattachedTruted the hostRun again, just to get again the messageThe host is not paired with the device.I do not see which and where I should pair.
Do you use third party framweworks, like Alamofire ?
One of my production Mac is still on Mojave. I want to update to Catalina and not Big Sur (waiting for dust to settle down).
Automatic update from system preferences only proposes Big Sur as well as some patch updates for MacOS 10.14.6
What is the safe and sure way to update from Mojave to the latest Catalina ?
I have created a new entry in the capability list (background modes)
None is selected, so that seems to have no effect.
However, I would like to remove this entry to clean the screen. But I cannot find any "-" button, nor contextual menu, nor editing in XML…
Is it simply possible to remove ?
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 ?
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 ?
I get a surprising crash when adapting constraints.
Xcode 13.2.1
iOS 15.2 on simulator
Here is the set up in storyboard:
A subclass of UIView (PopoverView) to draw a popover like frame and label and button inside.
PopoverView can set its arrow position all around, for instance on the right, so that popover will appear on the left of an object,
or on the left, to appear on the right.
Button tap is used to loop through the arrow position.
I have defined constraints (and their IBOutlets), and notably for the centerX position of popoverView to centerX of the label.
I adapt the value of the constraints in viewWillLayoutSubviews to position the popover in correct position relative to the label.
Now the problem.
To position the popover on the right of the label, I set its centerX constraint as follows in viewWillLayoutSubviews():
popoverCenterToLabelCenterConstraint.constant = (popoverLabel.frame.width + label.frame.width) / 2
That works OK
To position the popover on the left of the label, I set its constraint as follows (offset the opposite value):
popoverCenterToLabelCenterConstraint.constant = -(popoverLabel.frame.width + label.frame.width) / 2
I also tried:
popoverCenterToLabelCenterConstraint.constant = -popoverLabel.frame.width / 2 - label.frame.width / 2
App does not crash but hangs, apparently in an infinite loop.
Idem if I divide by 2.0 instead of 2 : label.frame.width / 2.0
The width of the label, at this point of code, is 92.33333333333333
So I replaced by the value directly:
popoverCenterToLabelCenterConstraint.constant = -popoverLabel.frame.width / 2 - 46.2
and it works OK. Idem with 46.1
So the problem is not due to the position of popoverView
If I replace the div by 2 by 2.01 :
- popoverCenterToLabelCenterConstraint.constant = -popoverLabel.frame.width / 2 - label.frame.width / 2.01
it works !!!!!!
Conclusion: it is the exact div by 2 that causes the hanging.
What could be the reason for this strange behaviour ?
That's a follow up of a previous thread.
https://developer.apple.com/forums/thread/707130
I did some test on iOS 16 simulator with Xcode 14ß.
Recognition is very poor. And recognition rate of some single letters (an L or an I for instance) is zero (literally). Same code worked better (success 50% for same single letters) with iOS 15.2.
Did something change on iOS 16 ? I filed a bug report: Jun 7, 2022 at 3:28 PM – FB10066541