NSInvalidUnarchiveOperationException cannot decode object error in Apple Watch extension

前端 未结 1 1227
灰色年华
灰色年华 2021-01-02 11:29

I\'ve got a user object that I need to store in NSUserDefaults and share with an iOS 8 extension app (Watchkit). In the main container app, I can encode and decode the objec

相关标签:
1条回答
  • 2021-01-02 11:57

    For your WatchKit Extension to be able to decode SFUserAccount objects, it needs to understand the SFUserAccount class. To enable this, it should be added to your WatchKit Extension.

    1. Click on your project name in the Project Navigator, at the top of the left column in Xcode. (Press Cmd-1 to show the Project Navigator if it is hidden.
    2. Click to highlight the name of your WatchKit Extension on the left of the main window, under 'Targets'. (NOTE: highlight your WatchKit Extension, not the WatchKit App.
    3. Select 'Build Phases' in the items across the top.
    4. Next to 'Compile Sources', use the disclosure triangle to view the section if it is not already visible.
    5. Click the '+' at the bottom of the section to add a new source.
    6. From the list, select the .m file for the Class you need to add (in this case, the SFUserAccount.m file).
    7. Click 'Add'.
    8. Build and run.
    0 讨论(0)
提交回复
热议问题