0

I'm newbie that learning swift, and I try to define property in objC souce, but then I have no idea that access it from my swift code :(

foo.h

#import "RCTView.h"


@interface Foo : RCTView

@property (nonatomic, assign) NSString *config;

@end

foo.m

#import "foo.h"
#import "RCTViewManager.h"
#import "RCTBridgeModule.h"


@interface RCT_EXTERN_MODULE(Foo, RCTViewManager)

RCT_EXPORT_VIEW_PROPERTY(config, NSString);

@end

foo.swift

import Foundation


@objc(Foo)
class Foo :  {

struct Foo
  {
    static var bar = ""
  }

  func setConfig(config: String!) {
    Foo.bar = config
  }

}

now I just through struct to get property config value, how could I get it directly from swift code?

thanks for your time.

L.Jovi
  • 1,631
  • 4
  • 22
  • 36

1 Answers1

0

If you want to use swift and objective-c in the same project, then you have to use a bridging header which connects swift to objective-c. Here is the official documentation: https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html

This question should help you: Can't use Swift classes inside Objective-C

Community
  • 1
  • 1
rgamber
  • 5,749
  • 10
  • 55
  • 99