Cannot Decode Object of Class (Ampathpopupbutton)'

NSKeyedUnarchiver decodeObjectForKey: cannot decode object of class AMPathPopUpButton for key NS.objects

To satisfy this error and get your popup's UI elements building/showing takes two simple steps:

  1. Add the "Automator.framework" in your project's "General" setting page. See this answer here: https://stackoverflow.com/a/25667439/1762493
  2. Then be sure to link the elements in your popup to an @IBOutlet variable like so: @IBOutlet var imgPath: NSPathCell!. Once you add the @IBOutlet var you have to drag your mouse and connect it to the UI element. You'll need an @IBOutlet or @IBAction for each element you drew in the Main.storyboard like so:

Xcode screenshot dragging IBOutlet variable to Main.storyboard UI element

There's a good tutorial at RayWenderlich.com for creating a popup and adding UI elements connected to Main.storyboard for MacOS apps here:

https://www.raywenderlich.com/450-menus-and-popovers-in-menu-bar-apps-for-macos

SpriteKit scene is blank on iOS 8

You were probably using features not available to iOS 7 or 8 in your Scene. You can declare certain code blocks as only being activated for certain iOS versions, but if you are using something like a critical features such as a camera node then you may need to increase your deployment target, or use an old-fashioned camera.

This link shows how to implement an old-school camera:
https://developer.apple.com/library/content/documentation/GraphicsAnimation/Conceptual/SpriteKit_PG/Actions/Actions.html

and you can use https://objectivec2swift.com/#/home/converter/ to convert snippets to Swift if needed.

If you aren't using camera node, try checking in your .sks files for any references to one.. there is an option called 'use camera' that is checked by default for your base Scene in the editor, regardless of whether you have made one:

Sample Image

I've found that random errors without stack traces to a line of code are typically caused from issues with a .sks or other non-swift file type <.<()

UPDATE:

After snooping around this seems to be a bug or a problem without a clear solution. My final two solutions would be:

  1. Drop iOS 7 and see if iOS 8+ gives you the error (which I thought 8 was the lowest target anyway).. with so few users and features I doubt it is worth supporting 7... but, if you must:

  2. Download Xcode 7 (or earlier) and simply make two projects.
    http://adcdownload.apple.com/Developer_Tools/Xcode_7.3.1/Xcode_7.3.1.dmg

If you take that route, I would suggest developing in XC7 so that way you can share Swift 2.3 code across iOS 9 / 10, or use the built in features to convert to swift 3 later on.

How can I decode an object when original class is not available?

If the name of the class in Objective-C is important, you need to explicitly specify the name. Otherwise, Swift will provide some mangled name.

@objc(Person)
class PersonOldVersion: NSObject, NSCoding {
var name = ""
var lastName = ""
}

Added a custom framework, now Swift can't unarchive data

Moving DemoNote from the app to a framework did change the module name, which meant that NSKeyedUnarchiver couldn't find instances of the archived class due to a name mismatch. The fix was to add this line before unarchiving:

NSKeyedUnarchiver.setClass(DemoNote.self, forClassName: "DemoNotesSwift.DemoNote")

In this case, DemoNote.self gets the current full class name, and DemoNotesSwift.DemoNote is what the class used to be called when it was part of the app.

This was only necessary because I had previously existing data that I wanted to keep.



Related Topics



Leave a reply



Submit