zoukankan      html  css  js  c++  java
  • OC调用Swift

    Step by step swift integration for Xcode Objc-based project:

    1. Create new *.swift file (in Xcode) or add it by using Finder
    2. Add swift bridging empty header if Xcode have not done this before (see 4 below)
    3. Implement your Swift class by using @objc attribute:

      import UIKit
      
      @objc class Hello: NSObject {
          func sayHello() {
              print("Hi there!")
          }
      }
    4. Open Build Settings and check those parameters:
      • Product Module Name : myproject
      • Defines Module : YES
      • Embedded Content Contains Swift : YES
      • Install Objective-C Compatibility Header : YES
      • Objective-C Bridging Header : $(SRCROOT)/Sources/SwiftBridging.h
    5. Import header (which is auto generated by Xcode) in your *.m file

      #import "myproject-Swift.h"
    6. Clean and rebuild your Xcode project
    7. Profit!
  • 相关阅读:
    生成器
    迭代器
    闭包函数
    装饰器(2)
    装饰器(1)
    名称空间与作用域(2)
    110.网络编程-mail
    109.网络编程-FTP
    108.网络编程-TCP/UDP
    107.xpath
  • 原文地址:https://www.cnblogs.com/dzhs/p/5500747.html
Copyright © 2011-2022 走看看