Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Swift 3 #1

Open
frcocoatst opened this issue Nov 10, 2016 · 14 comments
Open

Problem with Swift 3 #1

frcocoatst opened this issue Nov 10, 2016 · 14 comments

Comments

@frcocoatst
Copy link

frcocoatst commented Nov 10, 2016

I updated to Swift 3 and after conversion it looks like I cannot read the archived struct.
Any idea what I did wrong?

@frcocoatst
Copy link
Author

Archiv.zip

@vishalvshekkar
Copy link
Owner

I haven't yet converted these files in Swift 3.0

Give me some time, I'll look into it.

@frcocoatst
Copy link
Author

Thanks! Somehow the unarchiving seems to return nil ....

@vishalvshekkar
Copy link
Owner

vishalvshekkar commented Nov 11, 2016

Yes, I believe there's some change in the folder hierarchy or the way file URLs are handled in Swift 3.0 on a playground.

Can you try archiving it into UserDefaults and unarchiving from it instead of a file?
That should work. Let me know how it goes.

I'll work on conversion and release an update soon.

@frcocoatst
Copy link
Author

Very strange.
I tried to make a macOS Playground, but get the same problem. The file is definitely at /tmp/moviedata
But reading back fails....
ArchivingSwiftStructures1.playground.zip

@frcocoatst
Copy link
Author

The same with classes seems to work
MyNSCoderMacOsPlayground.playground.zip

@OptTrader
Copy link

Yeah, I have trouble with conversion also specifically with the the stringappendingstring. Can you also show how to do this with an array of movie objects?

@frcocoatst
Copy link
Author

Hmmm, no idea what is wrong ...

@vishalvshekkar
Copy link
Owner

vishalvshekkar commented Nov 24, 2016

Okay, I got the ArchivingSwiftStructures3.playground working in Swift 3. The file's been attached below.

I suspect the problem came up because NSKeyedArchiver and UserDefaults class now use 'Any' type instead of 'AnyObject'. This is causing havoc with class type objects. I'll update the repo with Swift 3 files soon. See if what I've attached suffices for now.

ArchivingSwiftStructures3_Converted_Swift3.playground.zip

@frcocoatst
Copy link
Author

Works perfect! Thanks a lot!

@frcocoatst
Copy link
Author

Hi!
Just found one problem (Maybe I'm doing anything wrong). I tried to store an array of structs of NSPoints.
But it fails with "Argument type '[Points]' does not conform to expected type 'Dictionariable'"
MyArchivePointsPlayground.playground.zip

Do you have any idea, how to solve this?
Thanks

@vishalvshekkar
Copy link
Owner

vishalvshekkar commented Nov 28, 2016 via email

@frcocoatst
Copy link
Author

Thanks a lot this helped.
So I now have two extensions - one for Points structure and one for NSPoint. Right?

MyArchivePointsPlayground.playground.zip

@vishalvshekkar
Copy link
Owner

Awesome.
Yes, that's right. You extend both Points and NSPoint to conform to Dictionariable protocol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants