ios - Integrate swift in objective c framewok -
i starting objective framework , wanna integrating swift code in it. according official document. (https://developer.apple.com/library/ios/documentation/swift/conceptual/buildingcocoaapps/mixandmatch.html#//apple_ref/doc/uid/tp40014216-ch10-xid_78)
because generated header framework target part of framework’s public interface, declarations marked public modifier appear in generated header framework target. can still use swift methods , properties marked internal modifier within objective-c part of framework, long declared within class inherits objective-c class.
however, found impossible access internal part of swift like:
@objc internal class a: nsobject {}
the quote says “you can still use swift methods , properties marked internal modifier” (emphasis added). in example class (not method or property) internal
. if make class public
, add internal method, should able access method.
edit: following works me:
swift:
@objc public class myclass : nsobject { internal func bar() -> string { return "foobar" } }
objective-c:
#import "myapplication-swift.h" myclass *foo = [[myclass alloc] init]; nslog(@"%@", [foo bar]);
note code must built generated myapplication-swift.h
updated.
Comments
Post a Comment