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

@synthesize of 'weak' property is only allowed in ARC or GC mode #104

Closed
loretoparisi opened this issue Feb 19, 2016 · 8 comments
Closed

Comments

@loretoparisi
Copy link

/MusiXmatch/3rdParty/SPTDataLoader/SPTDataLoader/SPTDataLoaderCancellationTokenImplementation.m:57:13: @synthesize of 'weak' property is only allowed in ARC or GC mode

Is the library a ARC project?

@rastersize
Copy link
Contributor

Hey @loretoparisi,

It’s indeed an ARC project. It looks like you need to init our submodules, which contains an Xcode config file defining almost all of our settings. Including the “use ARC” one.

Running the following command from the root of the project and then re-opening the Xcode workspace should resolve the issue:

git submodule update --init

@loretoparisi
Copy link
Author

@rastersize right I initialized the submodules, cleaned up, it fixed that error, but now I get

/MusiXmatch/3rdParty/SPTDataLoader/demo/PlaylistsViewModel.m:113:76: error: implicit conversion from nullable pointer 'NSData * _Nullable' to non-nullable pointer type 'NSData * _Nonnull' [-Werror,-Wnullable-to-nonnull-conversion]
    NSDictionary *jsonDictionary = [NSJSONSerialization JSONObjectWithData:response.body

since the property is nullable

@Property (nonatomic, strong, readonly, nullable) NSData *body;

Ok it's something else since I get this in several locations like:

/MusiXmatch/3rdParty/SPTDataLoader/demo/SPTDataLoaderAuthoriserOAuth.m:141:77: error: implicit conversion from nullable pointer 'NSData * _Nullable' to non-nullable pointer type 'NSData * _Nonnull' [-Werror,-Wnullable-to-nonnull-conversion]
    NSDictionary *tokenDictionary = [NSJSONSerialization JSONObjectWithData:response.body
                                                                            ^
/MusiXmatch/3rdParty/SPTDataLoader/demo/SPTDataLoaderAuthoriserOAuth.m:164:105: error: implicit conversion from nullable pointer 'NSError * _Nullable' to non-nullable pointer type 'NSError * _Nonnull' [-Werror,-Wnullable-to-nonnull-conversion]
            [self.delegate dataLoaderAuthoriser:self didFailToAuthoriseRequest:pendingRequest withError:response.error];

@loretoparisi
Copy link
Author

Should'n it an unwrap like

NSDictionary *jsonDictionary=nil;
    NSData *responseBody=response.body;
    if(responseBody) {
        jsonDictionary = [NSJSONSerialization JSONObjectWithData:responseBody
                                                                   options:NSJSONReadingAllowFragments
                                                                     error:&error];
    }

    if (!jsonDictionary) {
        NSLog(@"Error: %@", error);
        return;
    }

@loretoparisi
Copy link
Author

I was able to fix after unwrapping all those ones like in AppDelegate.m where I had two:

NSError *error = nil;
    NSDictionary *oauthTokenDictionary = nil;
    NSData *responseBody=response.body;
    if(responseBody) {
       oauthTokenDictionary = [NSJSONSerialization JSONObjectWithData:responseBody
                                                                         options:NSJSONReadingAllowFragments
                                                                           error:&error];
    }

and in

- (void)dataLoader:(SPTDataLoader *)dataLoader didReceiveErrorResponse:(SPTDataLoaderResponse *)response
{
    @synchronized(self.pendingRequests) {
        for (SPTDataLoaderRequest *pendingRequest in self.pendingRequests) {
            NSError *error=response.error;
            [self.delegate dataLoaderAuthoriser:self didFailToAuthoriseRequest:pendingRequest withError:error];
        }
    }
}

rastersize added a commit that referenced this issue Feb 19, 2016
- Explicitly unwraps the properties that might be nil.
- Resolves #104.
@rastersize
Copy link
Contributor

@loretoparisi Ah yes, thank you! I’ve created a PR that should fix these, #105.

rastersize added a commit that referenced this issue Feb 19, 2016
- Explicitly unwraps the properties that might be nil.
- Resolves #104.
@loretoparisi
Copy link
Author

+1

the last one was in SPTDataLoaderAuthoriserOAuth.m

here

#pragma mark SPTDataLoaderDelegate

- (void)dataLoader:(SPTDataLoader *)dataLoader didReceiveSuccessfulResponse:(SPTDataLoaderResponse *)response
{
    NSError *error = nil;
    NSDictionary *tokenDictionary = nil;
    NSData *responseBody=response.body;
    if(responseBody) {
        tokenDictionary = [NSJSONSerialization JSONObjectWithData:responseBody
                                                                    options:NSJSONReadingAllowFragments
                                                                      error:&error];
    }

@rastersize
Copy link
Contributor

@loretoparisi Thanks for taking the time to report the issue 🙇🎈

@loretoparisi
Copy link
Author

@rastersize you're welcome, thanks for share it, very interesting and useful! Closing then!

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