Post

Replies

Boosts

Views

Activity

Reply to access NSNotifications from iOS app on M1 Mac
I use cmdKey to create keyboard and menu shortcuts. The idea was to use the escape key to toggle between two windows. Of course, assigning the escape key to a custom shortcut interferes with its default behavior of "escaping" out of full screen mode. I wanted to avoid disturbing this default behavior. Detecting fullscreen mode, offers the chance to temporarily disable the custom shortcut, restoring the default behavior of the escape key.
Jun ’22
Reply to access NSNotifications from iOS app on M1 Mac
I've got a workaround. Going fullscreen triggers viewWillTransitionToSize. I get the new size.height and compare it to mainScreen.nativeBounds.height. If the new size.height >= nativeBounds.height, then I assume the app has gone fullscreen. An isFullScreen boolean is set here, and when the escape key is pressed, the shortcut is temporarily disabled, allowing default behavior for the escape key.
Jun ’22
Reply to access NSNotifications from iOS app on M1 Mac
I use cmdKey to create custom keyboard and menu shortcuts. I wanted to use the escape key to switch between two screens, but this disabled the default behavior for the escape key on the Mac (exiting fullscreen mode). Detecting fullscreen mode would offer a chance to temporally disable the custom shortcut, restoring default behavior (escaping from fullscreen mode with the escape key). My workaround so far is to compare the updated size.height to mainScreen.nativeBounds.height within viewWillTransitionToSize(). If size.height >= nativeBounds.height, then I assume we're in fullscreen mode. I set a boolean isFullScreen, which disables the custom shortcut within the validateCommand() method.
Jun ’22
Reply to Airdropping Core Data
Excellent question. I'm working on the same thing. So far, I have been able to airdrop a record (to my M1 Mac from my M1 iPad Pro)successfully using this code: func shareDicta() {  //LOG1  let url = saveDicta("share")  print(url)  let activityVC = UIActivityViewController(activityItems:[url],applicationActivities:nil)  activityVC.title = "Share One"  activityVC.excludedActivityTypes = []  activityVC.popoverPresentationController?.sourceView = self.view  activityVC.popoverPresentationController?.sourceRect = CGRect(x:self.view.bounds.midX,y:self.view.bounds.midY,width:0,height:0)  self.present(activityVC, animated: true, completion: nil)    } //============= func saveDicta(_ fName: String) -> URL {  var dictaFName = ""  if(fName.count<1){return URL(string:"")!}  dictaFName = fName  let fetchRequest: NSFetchRequest = DictaData.fetchRequest()  fetchRequest.predicate = NSPredicate(format:"%K == %@","dictaUUID",svUUID as CVarArg as CVarArg)     fetchRequest.fetchLimit = 1  guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {return URL(string:"")!}  let context = appDelegate.persistentContainer.viewContext        do{   let dicta = try context.fetch(fetchRequest).first       do {    let dictaURL = try FileManager.default.url(for:.documentDirectory,in:.userDomainMask,appropriateFor:nil,     create:false).appendingPathComponent(dictaFName + ".dicta")    let data = try NSKeyedArchiver.archivedData(withRootObject:dicta as Any,requiringSecureCoding:false)    try data.write(to:dictaURL)      return dictaURL   }catch{    print("ERROR: (error.localizedDescription)")    return URL(string:"")!   }     }  catch let error as NSError {   print("DictaData FETCH FAILED. (error), (error.userInfo)")   return URL(string:"")!  }    } //============== When I send it back to my app on my iPad, I am struggling to read it back in, not to mention adding to the CoreData storage. Here's what I have so far on that end: @objc class func insertDicta(_ path: URL) {  print("DictateVC:(#function)");  print(path)  if(fm.fileExists(atPath:path.path)){       do{    let dData = try Data(contentsOf:path)         //let dicta = try! NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(dData) as! NSManagedObject    let dicta = try! NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(dData)    print(dData)         try fm.removeItem(at:path)    }catch let error as NSError{    print("Could not save. (error), (error.userInfo)")    //okAlert("Save Failed","")    return   }      } } I am able to read/load the record into 'dData' but on the next line, when I try 'NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(dData)' the app crashes with this error: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DictaData initWithCoder:]: unrecognized selector sent to instance 0x280939500' Here, DictData is the name of my CoreData entity. Anyway, I don't know if this helps at all, but I hope so. Can you let me know if you've discovered anything which works? I'm right in the middle of working on it, so any breakthroughs would be very helpful. BTW, the record my app sends to the Mac can be read with the TextEdit app, and looks like this: bplist00‘ X$versionY$archiverT$topX$objects � ܆_ NSKeyedArchiver— TrootÄ Ø )*.4DEKLRZ[_cdefgknopU$nullfi !"#$%&'(YdictaFnSzYdictaMlhfSurlUtitleYdictaFColYdictaIndxYdictaDateYdictaLocaYcanonTextYdictaLangV$classZdictaMonthYdictaUUIDYdictaFontÄ Ä Ä�Ä Ä Ä Ä Ä Ä Ä Ä Ä Ä Ä i0J0o0à0F0T0V0D00Y“+ ,-WNS.time#AƒDπzŸ¶ Ä “/012Z$classnameX$classesVNSDate¢13XNSObjectŸ56789: ;<=>??@AB>C_ UIColorComponentCountWUIGreenVUIBlueWUIAlphaUNSRGB_ UISystemColorNameUUIRed\NSColorSpace "����"?Ä��E0 0 1Ä Ä YblueColor”/0FGHI[$classhintsWUIColor¢G3°JWNSColor"B≤‚ ”M NOPQ_ UIFontDescriptorOptions_ UIFontDescriptorAttributes �Ä Ä ”ST UWYWNS.keysZNS.objects°VÄ °XÄ Ä _ NSFontFamilyAttribute_ American Typewriter“/0]^\NSDictionary¢]3“/0`a_ UIFontDescriptor¢b3_ UIFontDescriptor _ Japanese Uja-JA"=LÃÕ“h ij\NS.uuidbytesO Ô√˚ ∏C∏Öπt<&ŇRÄ “/0lmVNSUUID¢l3i0J0o0à0F0T0V0D00YW2022007“/0qrYDictaData£qs3_ NSManagedObject� � � �$�)�2�7�I�L�Q�S�n�t�ë�õ�•�©�Ø�π�√�Õ�◊�·�Î�Ú�˝ ! # % ' ) + - @ E M V X ] h q x { Ñ ó Ø ∑ æ ∆ à ‡ Ê Û ı ˙ ˇ ( 0 3 5 = B I c Ä Ç Ñ Ü ç ï † ¢ § ¶ ® ™ ¬ ÿ › Í Ì Ú 6 < A F S f h m t w ä í ó ° •������ �������t�������������� ∑ From my perspective, there is useful data there, so that if I could just load that data, as, I might be able to access this information, parse it, if you will, then reconstruct it into a format which could then be inserted into CoreData. Something like this: @objc func saveDicta() {  //print("(#function)")  if(edDict){saveEdit();return}     guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {return}  let managedContext = appDelegate.persistentContainer.viewContext  let entity = NSEntityDescription.entity(forEntityName:"DictaData",in:managedContext)!  let dicta = NSManagedObject(entity:entity,insertInto:managedContext)      dicta.setValue(self.textView.text,forKeyPath:"title")  dicta.setValue(local,   forKeyPath:"dictaLoca")  dicta.setValue(langu,   forKeyPath:"dictaLang")  dicta.setValue(index,   forKeyPath:"dictaIndx")  dicta.setValue(fgcol,   forKeyPath:"dictaFCol")  dicta.setValue(descr,   forKeyPath:"dictaFont")  dicta.setValue(fntSz,   forKeyPath:"dictaFnSz")  dicta.setValue(mlhfa,   forKeyPath:"dictaMlhf")  dicta.setValue(UUID(),  forKeyPath:"dictaUUID")  dicta.setValue(NSDate(), forKeyPath:"dictaDate")       do {   try managedContext.save()   dictas.append(dicta)  } catch let error as NSError {   print("Could not save. (error), (error.userInfo)")   okAlert("Save Failed","")   return  } } Good luck. Please let me know of any breakthroughs. --Jon
Jul ’22
Reply to UIGraphicsImageRenderer fails to render image from view
On Sept. 11, 2022, I started getting the same kind of error messages. I had recently made changes on constraints for a PDFView, the source for my screen shots. In my case, I had these constraints in the ViewDidLoad. I had deleted the constraints for TOP and BOTTOM. When I added them back the errors went away, and I was able to get perfect screen shots and save them to the Photos app. I'm sure it was a "frame" issue created by bad or missing constraints. Let me know how it goes. --Jon
Sep ’22