Error message: Duplicate declaration of method 'resolver:rejecter:'
RCT_REMAP_METHOD(get_data,
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock )reject)
{
dispatch_group_wait(self.group, DISPATCH_TIME_FOREVER);
[self compute_run_avg:^(NSMutableDictionary *result) {
resolve(result);
}];
}
RCT_REMAP_METHOD(send_count,
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
{
}
Can I export only one method which uses promises?
Shouldn't the scope be limited to exported method?
if not
How can I reuse the method then?
thanks
Name the methods get_data_resolver:rejecter: and send_count_resolver:rejecter:. The remap macro only sets up an alias to the method name you give it.
I tried that twice. Xcode gave me a C99 error.
After I quit Xcode and restarted my computer your solution works. 馃尩
Either way, is is not really a nice solution long term. It works but, I should be able to use ANY name I want within that method as with parameters in any and every other method. that's how I feel intuitively.
thinking that is maybe nonsense because I'm unfamiliar with macros and how they work under the hood. More of a Swifter...
thanks for explaining 馃挴 馃憤 鉂わ笍
You can use any name you want if you follow the rules of Objective-C. The macro defines an Objective-C method with the exact name that you give it.
What I mean is - if the exported method name is different from some other exported method name it should not matter whether the parameters are named same or not. In obj-c it won't complain if you have same parameter names in 2 distinct methods. But clearly that's not the case here 馃槄
Need to learn about macros... If you know of a resource that explains macros in a simple way I'd be delighted to read it. 馃弳
as always, thanks for finding the time to read and reply 馃挴
I think you're misreading the macro. It's RCT_REMAP_METHOD(alias, method), not RCT_REMAP_METHOD(alias, parameters).
@ide thanks
Most helpful comment
I think you're misreading the macro. It's RCT_REMAP_METHOD(alias, method), not RCT_REMAP_METHOD(alias, parameters).