吉林大学学报(信息科学版) ›› 2021, Vol. 39 ›› Issue (1): 106-113.

• • 上一篇    下一篇

基于 Runtime 的 iOS 编程研究与实现

胡 坤a,b, 特日根a,b#br# #br#   

  1. 长光卫星技术有限公司 a. 数据中心; b. 吉林省卫星遥感应用技术重点实验室, 长春 130000
  • 收稿日期:2020-05-21 出版日期:2021-03-19 发布日期:2021-03-22
  • 作者简介:胡坤(1992— ), 男, 长春人, 长光卫星技术有限公司助理工程师, 主要从事 iOS 软件开发与安卓软件开发研究,(Tel)86-18744023642(E-mail)1158607313@qq.com
  • 基金资助:
    国家重点研发计划基金资助项目(2018YFB1004605); 吉林省科技计划-科技创新中心基金资助项目(20180623058TC)

Research and Implementation of iOS Programming Based on Runtime Mechanism

HU Kuna,b, TE Rigena,b   

  1. a. Data Center; b. Key Laboratory of Satellite Remote Sensing Application Technology of Jilin Province, Changguang Satellite Technology Company Limited, Changchun 130000, China
  • Received:2020-05-21 Online:2021-03-19 Published:2021-03-22

摘要: 在 iOS 开发过程中, 因为系统自带方法对应的功能不足, 使部分业务需求不能有效地实现。 为此, 首先对 Runtime 库的主要 API 接口用途进行了研究, 找到可利用的接口; 然后对 Runtime 消息转发机制进行研究,证明函数调用的实质就是消息的传递; 最后通过实际案例, 证明了应用 Runtime 可以解决系统方法不足的问题。 结果表明, 通过 Runtime 库给系统自带的类动态添加或修改成员变量和成员方法具有可行性, 可为 iOS开发者提供参考和借鉴。

关键词: iOS 系统, 运行时机制, 函数调用, 动态修改

Abstract: In the process of iOS application development, due to the insufficient functions of the system's own methods, some business requirements can not be effectively realized. In order to solve this problem, the main API interface usage of the Runtime library is studied and the available interfaces are found. The message forwarding mechanism of Runtime is studied to prove that the essence of the function call is the transmission of messages. And through actual cases, it proves that the application of Runtime can solve the problems caused by the lack of system methods. Therefore, it can dynamically add or modify member variables and member methods of the system's own classes through the Runtime library. And finally it is proved that the use of Runtime library can solve the problem of insufficient functions of the system, which can provide reference for iOS developers.

Key words: iOS system, runtime mechanism, function call, dynamic modification

中图分类号: 

  • TP311. 5