Post

Replies

Boosts

Views

Activity

How much space needed for Mac OS 10.16?
I just upgraded to 10.15.6 beta 3 then straight away I'm offered 10.16! There is no 10.16 on the dev website. When I try installing it says it needs another 7Gb. There is already 53Gb available, so what is going on here? I've also read that 10.16 is actually Bug Sur beta masquerading as Catalina and I haven't elected to beta test Big Sur so, again, what is going on?
1
0
468
Jul ’20
Dynamically change size of UIViewRepresentable
I have a UIView embedded in a UIViewRepresentable. I need this view to be movable and resizable. I can get it to move, but not resize, inasmuch as its frame size changes, but it isn't redrawn at the new size. I need some way for the view to communicate the size change to its SwiftUI container and for that to redraw it. Any suggestions?
0
0
868
Jul ’20
ToolbarItem not compiling
I have a .toolbar modifier that contains ToolbarItems. The compiler is failing with 'ToolbarItem' is only available in iOS 14.0 or newer'. I have Xcode 12 beta 2 installed, the deployment target set to iOS 14 and a simulator running ios14. This looks like a beta version error. Has anyone else encountered it?
1
0
650
Jul ’20
SwiftUI EditButton still not working
I have been developing a SwiftUI app for about a year now. From the early days the UI had EditButtons working OK. These stopped working when Xcode 12 came along. I reported this to the Feedback assistant, but have a had no reply. The issue is still there in the latest release candidate 12.2 beta 4. The code below is the test app I sent to Apple. It works if you remove .navigationViewStyle (in this test app, but not in my app). If anyone thinks I have made a mistake and that the issue is down to me, please let me know, otherwise if anyone from Apple is reading this please fix it. It seems rather fundamental to me. import SwiftUI struct ContentView: View {     @State private var myArray: [String] = ["One", "Two", "Three"]     var body: some View {         NavigationView {             VStack {                 List {                     ForEach(myArray, id: \.self) { item in                         Text(item)                     }                     .onDelete { indexSet in                         myArray.remove(atOffsets: indexSet)                     }                 }             }             .navigationBarTitle("Navigation")             .navigationBarItems(trailing: EditButton())         }.navigationViewStyle(StackNavigationViewStyle())     } } struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView()     } }
10
0
4k
Nov ’20
Help! lldb po command suddenly stopped working
For no apparent reason the po command has stopped working. It simply produces no output, no errors, nowt! I haven't changed Xcode (I am using v12 beta 3 for new work and v12.2 for production. Both are failing. The problem began today with v12.2 while I was working with the Test App. I've tried a clean build, restarting Xcode and rebooting. I've even tried it on a production app with the same results. So, at this point in time I am scuppered. Any suggestions most welcome.
1
1
1.4k
Dec ’20
Error initialising UnsafeMutablePointer<ObjCBool>
The following code compiles ok in one function:         let stop:UnsafeMutablePointerObjCBool stop.initialize(to: false) text.enumerateAttribute(kStyleKey,                                 in: NSRange(location: 0, length: text.string.count),                                 options: []) { (value, range, stop) in but the following code which is virtually the same fails the initialise with the error "Constant 'stop' being used before being initialised" :         let stop:UnsafeMutablePointerObjCBool stop.initialize(to: false) attributedText.enumerateAttribute(kStyleKey,                                           in: NSRange(location: selectedRange.location, length: selectedRange.length),                                 options: []) { (value, range, stop) in Any suggestions - looks like a compiler issue to me.
10
0
2.1k
Mar ’21
Defining Transformer for NSAttributedString
Coredata used to save attributed strings, but now requires a secure coding transformer. I have tried the code below, but it fails claiming This decoder will only decode classes that adopt NSSecureCoding. Class '__SwiftValue' does not adopt it The transformer has been registered and the attributes given the name 'AttributedStringToDataTransformer' Any suggestions as to what is wrong? Here's the code: class AttributedStringToDataTransformer: ValueTransformer {     override func transformedValue(_ value: Any?) - Any? {         let boxedData = try! NSKeyedArchiver.archivedData(withRootObject: value!, requiringSecureCoding: true)         return boxedData   }     override func reverseTransformedValue(_ value: Any?) - Any? {         let typedBlob = value as! Data         let data = try! NSKeyedUnarchiver.unarchivedObject(ofClasses: [NSAttributedString.self], from: typedBlob)         return (data as! NSAttributedString)     } } extension AttributedStringToDataTransformer {     /// The name of the transformer. This is the name used to register the transformer using `ValueTransformer.setValueTrandformer(_"forName:)`.     static let name = NSValueTransformerName(rawValue: String(describing: AttributedStringToDataTransformer.self))     /// Registers the value transformer with `ValueTransformer`.     public static func register() {        ValueTransformer.setValueTransformer(AttributedStringToDataTransformer(), forName: name)     } }
1
0
820
Mar ’21
Dynamic type & custom font
If I call let font = UIFont.preferredFont(forTextStyle:.body) Then font.pointSize has value 17 If, however, I call this with a font such as Arial             let font = UIFont.fontWithNameAndTraits(fontName,                                                     size: styleAttributes.fontSize ?? 12,                                                     bold: styleAttributes.bold ?? false,                                                     italic: styleAttributes.italic ?? false)             let fontMetrics = UIFontMetrics(forTextStyle: .body)             let scaledFont = fontMetrics.scaledFont(for: font) Then scaledFont.pointSize has value 12. I was expecting 17, so I must be doing something wrong. Any suggestion? The function fontWithNameAndTraits is:     class func fontWithNameAndTraits(_ name:String, size:CGFloat, bold:Bool, italic:Bool)-UIFont {         let fontRef = UIFont.getFontRefForNameAndTraits(name, size:size, bold:bold, italic:italic)         let fontNameKey = CTFontCopyName(fontRef , kCTFontPostScriptNameKey)! as String         return UIFont(name: fontNameKey as String, size:CTFontGetSize(fontRef ))!     }
1
0
935
Apr ’21
TextKit 2 viewport
TextKit 2 looks great. The video demonstrates the sample app on both MacOS and iPad. However the downloaded code only works on MacOS and the documentation says the NSTextViewportLayoutController is only available on MacOS, so when can we expect the IOS versions. And what about integration with SwiftUI?
2
0
1k
Jun ’21
NSAttributedString attribute in CoreData
I have an NSAttributedString attribute in an entity marked as Transformable with the transformer set to NSSecureUnarchiveFromDataTransformerName. I have a Transformer defined as: class AttributedStringTransformer: NSSecureUnarchiveFromDataTransformer {     override class func allowsReverseTransformation() -> Bool {         return true     }     override class func transformedValueClass() -> AnyClass {         return NSAttributedString.self     }     override class var allowedTopLevelClasses: [AnyClass] {         return [NSAttributedString.self]     }     override func transformedValue(_ value: Any?) -> Any? {         guard let data = value as? Data else {             fatalError("Wrong data type: value must be a Data object; received \(type(of: value))")         }         return super.transformedValue(data)     }     override func reverseTransformedValue(_ value: Any?) -> Any? {         guard let string = value as? NSAttributedString else {             fatalError("Wrong data type: value must be a Reminder object; received \(type(of: value))")         }         return super.reverseTransformedValue(string)     } } extension AttributedStringTransformer {     /// The name of the transformer. This is the name used to register the transformer using `ValueTransformer.setValueTrandformer(_"forName:)`.     static let name = NSValueTransformerName(rawValue: String(describing: AttributedStringTransformer.self))     /// Registers the value transformer with `ValueTransformer`.     public static func register() {         let transformer = AttributedStringTransformer()         ValueTransformer.setValueTransformer(transformer, forName: name)     } } The transformer is registered on launch. When I launch the app with the string initialised to an empty attributed string the app fails right away with: CoreData: error: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x6000005679c0> , <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo of (null) 2021-08-12 08:53:30.390456+0100 Easiwriter[5985:108985] [error] error: -executeRequest: encountered exception = <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo = (null) CoreData: error: -executeRequest: encountered exception = <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo = (null) 2021-08-12 08:53:30.391637+0100 Easiwriter[5985:108985] [error] error: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x600000550a80> , <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo of (null) CoreData: error: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x600000550a80> , <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo of (null) 2021-08-12 08:53:30.458505+0100 Easiwriter[5985:108985] [error] error: -executeRequest: encountered exception = <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo = (null) CoreData: error: -executeRequest: encountered exception = <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo = (null) 2021-08-12 08:53:30.459614+0100 Easiwriter[5985:108985] [error] error: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x600000550a80> , <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo of (null) CoreData: error: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x600000550a80> , <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo of (null) 2021-08-12 08:53:30.459835+0100 Easiwriter[5985:108985] [error] error: -executeRequest: encountered exception = <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo = (null) CoreData: error: -executeRequest: encountered exception = <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo = (null) 2021-08-12 08:53:30.471535+0100 Easiwriter[5985:108985] [error] error: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x60000056d8c0> , <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo of (null) CoreData: error: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x60000056d8c0> , <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo of (null) I have put break points on the transformer, but it never hits them. The behaviour of the app gives me the feeling that this is a bug in CoreData, but I can't pin it down. Can someone please suggest what might be wrong. I am using Xcode 13.0 beta 5 (it failed on beta 4 as well).
0
0
809
Aug ’21