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

Crash when get the fullScreenImage in Xcode 6.4 #14

Closed
kshan opened this issue Sep 8, 2015 · 5 comments
Closed

Crash when get the fullScreenImage in Xcode 6.4 #14

kshan opened this issue Sep 8, 2015 · 5 comments
Labels

Comments

@kshan
Copy link

kshan commented Sep 8, 2015

invalid attempt to access <ALAssetPrivate: 0x7f8946220cd0> past the lifetime of its owning ALAssetsLibrary
fatal error: unexpectedly found nil while unwrapping an Optional value

How to solove it?

@zhangao0086
Copy link
Owner

Hi @kshan

The type of fullScreenImage is Optional, maybe you have to check it nil or not like this:

if let fullScreenImage = asset.fullScreenImage {
    // do something...
}

Thanks for your used :)
Closing the thread... Let me know if you have any other questions :)

@kshan
Copy link
Author

kshan commented Sep 9, 2015

@zhangao0086 Thanks for your prompt reply. I found the solution to this in my case.

Crash happen to that I post data to server via fullScreenImage, but use thumbnailImage in collectionview after picks phtos, even if unwrapping an optional value. If i use fullScreenImage in collectionview too, it's normal.

@zhangao0086
Copy link
Owner

Thanks for your detail!

Could you make a test? Change these line:

public private(set) lazy var fullScreenImage: UIImage? = {
    return UIImage(CGImage: self.originalAsset?.defaultRepresentation().fullScreenImage().takeUnretainedValue())
}()

to that:

public private(set) lazy var fullScreenImage: UIImage? = {
    return UIImage(CGImage: self.originalAsset?.defaultRepresentation().fullScreenImage(). takeRetainedValue())
}()

I think this will resolve your issue. Let me know if that works. TIA :)

@nishantdongare
Copy link

Hello @zhangao0086 . I tried to do this . But this is also not working. I am using iOS 9.0

@zhangao0086 zhangao0086 reopened this Oct 18, 2015
@zhangao0086
Copy link
Owner

Hi @nishantdongare @kshan

The issue has been fixed. Here is my solution:

  1. Define the library as a singleton property:static private let library = ALAssetsLibrary()
  2. Replace self.library.enumerateGroupsWithTypes... with self.dynamicType.library.enumerateGroupsWithTypes...

This will always use the same library for all accesses to the assets.
Let me know if you have any other questions :)

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

No branches or pull requests

3 participants