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

Wrong nullability flags on SPTPersistentCacheResponse #86

Closed
dral3x opened this issue Jan 18, 2017 · 4 comments
Closed

Wrong nullability flags on SPTPersistentCacheResponse #86

dral3x opened this issue Jan 18, 2017 · 4 comments

Comments

@dral3x
Copy link

dral3x commented Jan 18, 2017

The interface of SPTPersistentCacheResponse tells the compiler that all its properties are NONNULL but it's obvious that it's not true, you cannot have result and error instantiated at the same time.

This is a big issue in Swift3 projects, because if you check directly the presence of record without checking result before, the app will crash at runtime, because the compiler cannot let you use optional access to these properties.

A corrected version of it could be

@interface SPTPersistentCacheResponse : NSObject

/**
 * @see SPTPersistentCacheResponseCode
 */
@property (nonatomic, assign, readonly) SPTPersistentCacheResponseCode result;
/**
 * Defines error of response if appliable
 */
@property (nonatomic, strong, readonly, nullable) NSError *error;
/**
 * @see SPTPersistentCacheRecord
 */
@property (nonatomic, strong, readonly, nullable) SPTPersistentCacheRecord *record;

@end
@rastersize rastersize added the bug label Jan 18, 2017
@rastersize
Copy link
Contributor

Thanks for the report @dral3x, I’m assembling a PR to fix the issue.

@rastersize
Copy link
Contributor

@dral3x #87 should fix the issue.

@dral3x
Copy link
Author

dral3x commented Jan 18, 2017

Looking at the PR I agree with you.

Super fast fix @rastersize 👍

@rastersize
Copy link
Contributor

Closing as the PR has been merged.

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

No branches or pull requests

2 participants