ios-jsc icon indicating copy to clipboard operation
ios-jsc copied to clipboard

Cannot set `copy` NSString property on a protocol.

Open rajivnarayana opened this issue 7 years ago • 0 comments

Make sure to check the existing issues in this repository

Done that.

If there is no issue for your problem, tell us about it

I am developing a plugin to integrate FacebookAccountKit login into Nativescript but I am unable to set NSString property on an object when said property is in a protocol. I tried to use performSelectorWithObject and even tried to use NSInvocation but nothing worked. However, I am able to set other properties on the same object i.e. blackListedCountryCodes which is an NSArray and some boolean properties using performSelectorWithObject. There are no other string properties on this protocol.

I understand that we can invoke methods on a protocol something like AProtocol.prototype.methodName.call(anObject, arg1, ...) but, this is a property and I see Error: This is not a native object. when I try to access it.

Please, provide the following version numbers that your issue occurs with:

  • CLI: (run tns --version to fetch it) 4.1.0
  • Cross-platform modules: (check the 'version' attribute in the node_modules/tns-core-modules/package.json file in your project) ^4.0.0
  • Runtime(s): (look for the "tns-android" and "tns-ios" properties in the package.json file of your project) 4.0.1
  • Plugin(s): (look for the version numbers in the package.json file of your project and paste your dependencies and devDependencies here) Using https://github.com/NativeScript/nativescript-plugin-seed

Please, tell us how to recreate the issue in as much detail as possible.

Describe the steps to reproduce it. Clone repo https://github.com/rajivnarayana/nativescript-facebook-account-kit and go to src directory and type npm run demo.ios https://github.com/rajivnarayana/nativescript-facebook-account-kit/blob/master/src/facebook-account-kit.ios.ts#L113 Unable to set defaultCountryCode property on the facebook account kit view controller that opens eventually.

Is there any code involved?

My repo (a plugin) is at https://github.com/rajivnarayana/nativescript-facebook-account-kit

Find content from native Header files. The object that I am trying to set property on is of type AKFViewController

/*
  Defines the properties that can be configured for the Account Kit UI.
 */
@protocol AKFConfiguring

/**
  List of country codes to disallow.
 */
@property (nonatomic, copy) NSArray<NSString *> *blacklistedCountryCodes;

/**
  Specifies the default country code to select.
 */
@property (nonatomic, copy) NSString *defaultCountryCode;

// among others

The implementing object is declared as

@protocol AKFViewController <AKFUIManaging, AKFConfiguring>

rajivnarayana avatar Jul 03 '18 01:07 rajivnarayana