Swift 转 Object-C 一些知识点

  • Objective-C 说明

    Objective-C 能直接使用c、c++代码语言来混合使用。
    .h文件:定义一些类、属性、方法。
    .m文件:源代码文件,具体的方法实现。
    .mm文件:在需要和c++代码交互的时候需要使用该文件。

  • #import 指令

    以'#'开头 是预处理指令,也就是在编译之前。
    是 include指令的增强版,用来包含文件。在预编译时将所包含文件的内容copy到写指令的位置。
    增强的效果:首先impor指令无论你重复写几次只会copy一次内容,而include则是写几次就copy几次,如果想要使用include指令来达到只copy一次的效果则需要借助条件编译指令来实现。
    原理:import指令值包含的时候底层回去判断是否被包含,如果包含了就略过。

  • 在定义方法时

    1.有减号(-) 的方法为实例方法,必须使用类的实例才可以调用的。对应的有+号, 代表是类的静态方法,不需要实例化即可调用。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
SwiftUI is a new framework introduced by Apple in 2019 for building user interfaces on all Apple platforms (iOS, iPadOS, macOS, watchOS, and tvOS). It provides a new way of declaratively building user interfaces using Swift code. Objective-C, on the other hand, is an object-oriented programming language that has been widely used for building Mac and iOS applications. It has been around for much longer than SwiftUI, and has a large and established developer community. Here are some key differences between the two: 1. Syntax: SwiftUI has a simpler and more intuitive syntax compared to Objective-C, which can be more verbose and difficult to read. 2. Declarative vs Imperative: SwiftUI is a declarative framework, which means you describe what your user interface should look like, and the framework takes care of rendering it on the screen. Objective-C, on the other hand, is an imperative language, which requires you to write code to manipulate the user interface elements directly. 3. Interoperability: SwiftUI and Objective-C can coexist in the same project, and it is possible to use SwiftUI components in Objective-C code. However, the reverse is not true, as Objective-C code cannot be used in SwiftUI. 4. Learning Curve: SwiftUI is generally considered easier to learn for new developers, whereas Objective-C has a steeper learning curve. Ultimately, the choice between SwiftUI and Objective-C depends on the specific needs and preferences of each developer and the project they are working on. Both frameworks have their strengths and weaknesses, and both can be used to build high-quality and performant applications.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值