Attributes provide more information about a declaration or type. There are two kinds of attributes in Swift, those that apply to declarations and those that apply to types.

You specify an attribute by writing the @ symbol followed by the attribute’s name and any arguments that the attribute accepts:

  1. @attribute name
  2. @attribute name(attribute arguments)

Some declaration attributes accept arguments that specify more information about the attribute and how it applies to a particular declaration. These attribute arguments are enclosed in parentheses, and their format is defined by the attribute they belong to.

  1. @dynamicMemberLookup
  2. struct DynamicStruct {
  3. let dictionary = ["someDynamicMember": 325,
  4. "someOtherMember": 787]
  5. subscript(dynamicMember member: String) -> Int {
  6. return dictionary[member] ?? 1054
  7. }
  8. }
  9. let s = DynamicStruct()
  10. // Using dynamic member lookup
  11. let dynamic = s.someDynamicMember
  12. print(dynamic)
  13. // Prints "325"
  14. // Calling the underlying subscript directly
  15. let equivalent = s[dynamicMember: "someDynamicMember"]
  16. print(dynamic == equivalent)

https://docs.swift.org/swift-book/ReferenceManual/Attributes.html#grammar_attribute-argument-clause

swift 注解 (和java比照)@attribute name的更多相关文章

  1. 160919、使用AOP与注解记录Java日志

    有些时候,我想要把每个运行过的方法接收到的参数.返回值和执行时间等信息记录(通过slf4j 和 log4j)下来.在AspectJ.jcabi-aspects和Java注解的帮助下我实现了这个想法. ...

  2. Spring注解与Java元注解小结

    注解 Annotation 基于注解的开发,使得代码简洁,可读性高,简化的配置的同时也提高了开发的效率,尤其是SpringBoot的兴起,随着起步依赖和自动配置的完善,更是将基于注解的开发推到了新的高 ...

  3. 【转】Spring学习---Bean配置的三种方式(XML、注解、Java类)介绍与对比

    [原文]https://www.toutiao.com/i6594205115605844493/ Spring学习Bean配置的三种方式(XML.注解.Java类)介绍与对比 本文将详细介绍Spri ...

  4. 【JSON 注解】JSON循环引用2----JSON注解@JsonIgnoreProperties+JAVA关键字transient+后台对象与JSON数据的格式互相转化

    接着来说这个JSON循环引用的问题: 关于JSON格式的转化,其实关键就是这几个依赖: <!-- json --> <!-- 1号 --> <dependency> ...

  5. 使用XStream注解实现Java对象与XML互相转换的代码示例

    本文记录一下使用xstream这个api的注解特性对Java对象与XML字符串相互转换的一些代码示例.    我们很多人都处理过XML文件,也有很多非常成熟的第三方开源软件.如:jdom.dom4j等 ...

  6. Spring学习笔记1——IOC: 尽量使用注解以及java代码(转)

    在实战中学习Spring,本系列的最终目的是完成一个实现用户注册登录功能的项目. 预想的基本流程如下: 1.用户网站注册,填写用户名.密码.email.手机号信息,后台存入数据库后返回ok.(学习IO ...

  7. Spring学习笔记1——IOC: 尽量使用注解以及java代码

    在实战中学习Spring,本系列的最终目的是完成一个实现用户注册登录功能的项目. 预想的基本流程如下: 1.用户网站注册,填写用户名.密码.email.手机号信息,后台存入数据库后返回ok.(学习IO ...

  8. 了解注解及java提供的几个基本注解

    先通过@SuppreessWarnings的应用让大家直观地了解注解: 通过System.runFinalizersOnExit(true);的编译器警告引出           @SuppressW ...

  9. 注解:java 自定义注解应用实例

    本例子旨在使用自定义注解为实体打上标记,为自动生成 sql 提供依据,模拟 hibernate 的注解,至于注解的原理自己搜吧 1.定义 Table 注解 package test; import j ...

随机推荐

  1. 3.Servlet(二)

    1.Servlet应用开发接口 对Servlet应用开发接口及功能的掌握,决定了是否能做好Servlet开发工作. GenericServlet抽象类 HttpServlet抽象类 2.Servlet ...

  2. SQL 十分位

    -- 十分位,这个算法不是很准确 select family_agreement_cnt -- 字段 ,dt -- 分区 ,rn -- 排序 ,cnt -- 总行数 ,percent2 -- 分位值 ...

  3. python 和 C# DES加密

    C# code: using System; using System.IO; using System.Security.Cryptography; using System.Text; names ...

  4. 虚拟机安装MySQL报** is needed by **错误

    执行命令: [root@node1 local]# rpm -ivh mysql-community-server-8.0.12-1.el7.x86_64.rpm 安装MySQL遇到以下问题: err ...

  5. Mybatis学习笔记6 - #{}和${}

    #{}:可以获取map中的值或者pojo对象属性的值.${}:可以获取map中的值或者pojo对象属性的值. 区别: #{}:是以预编译的形式,将参数设置到sql语句中:PreparedStateme ...

  6. 关于imageview matrix

    Matrix 是 Android SDK 提供的一个矩阵类,它代表一个 3 X 3 的矩阵 那么这 9 个浮点数的作用和意义是什么呢,从 Android 官方文档上看,它为这个数组中的每一个元素都定义 ...

  7. How to Fold a Julia Fractal

    How to Fold a Julia FractalA tale of numbers that like to turn http://acko.net/blog/how-to-fold-a-ju ...

  8. ST-LINK接口定义

    ST-LINKIII管脚定义及接法:     ST-LINK IIILED灯三种状态含义: 常亮:目标板与ST-LINK在SWIM模式或者JTAG/SWD模式下已经通讯初始化. 闪烁:目标板与ST-L ...

  9. Unity [SerializeField]

    在Unity3d中Unity3D 中提供了非常方便的功能可以帮助用户将 成员变量 在Inspector中显示,并且定义Serialize关系. 也就是说凡是显示在Inspector 中的属性都同时具有 ...

  10. [转]javascript实现限制上传文件的大​​小

    本文转自:http://www.micmiu.com/lang/javascript/js-check-filesize/ 目录 基本思路 示例 [一].基本思路 在FireFox.Chrome浏览器 ...