Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

Missing parameter name in completion block causes an error #30

Closed
robinsalehjan opened this issue Jan 5, 2016 · 6 comments
Closed

Missing parameter name in completion block causes an error #30

robinsalehjan opened this issue Jan 5, 2016 · 6 comments

Comments

@robinsalehjan
Copy link
Contributor

Hi!

The method: performInNewBackgroundContext: is missing a parameter name in the completion block.

//The method is declared like this in the current bridging header:
[self.dataStack performInNewBackgroundContext:^(NSManagedObjectContext * _Nonnull) {
        <#code#>
    }];

//It should be declared like this:
[self.dataStack performInNewBackgroundContext:^(NSManagedObjectContext * _Nonnull backgroundContext) {
        <#code#>
    }];
@3lvis
Copy link
Owner

3lvis commented Jan 5, 2016

How would you fix that?

@robinsalehjan robinsalehjan changed the title Missing argument name in completion block causes an error Missing parameter name in completion block causes an error Jan 6, 2016
@robinsalehjan
Copy link
Contributor Author

The problem is that the parameter name in the block, declared in the method performInNewBackgroundContext: is missing.

Im not very familiar with Swift or generating bridging headers.
**I am assuming that Xcode is translating the function declaration in Swift to Objective-C methods, available in the header.

In the class DATAStack.swift the function is declared as:

public func performInNewBackgroundContext(operation: (backgroundContext: NSManagedObjectContext) -> ()) {
   <#code#>
}

Could changing the function declaration to

public func performInNewBackgroundContext(operation: (backgroundContext: NSManagedObjectContext) -> Void) {
   <#code#>
}

Then generating new bridging headers solve the issue?

@3lvis
Copy link
Owner

3lvis commented Jan 6, 2016

I sincerely think that this isn't something that we can fix, but I might be wrong.

Changing -> () for -> Void changes nothing because they are equivalent.

@robinsalehjan
Copy link
Contributor Author

Yes, I agree.
What about mentioning the issue in the "Background Thread NSManagedObjectContext" under the "Objective-C" section?

@3lvis
Copy link
Owner

3lvis commented Jan 7, 2016

That's a good idea!

@robinsalehjan
Copy link
Contributor Author

Great, I will close this issue and make a pull request.

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

No branches or pull requests

2 participants