core.attribute - D Programming Language

Menu

- Learn
- Documentation
  - Language Reference
  - Library Reference
  - Command-line Reference
  - Feature Overview
  - Articles
- Downloads
- Packages
- Community
  - Blog
  - Orgs using D
  - Twitter
  - Calendar
  - Forums
  - IRC
  - Wiki
  - GitHub
  - Issues
  - Get involved
  - Contributors
  - Foundation
  - Security Team
  - Donate
  - Sponsors
- Resources
  - Tour
  - Books
  - Tutorials
  - Tools
  - Editors
  - IDEs
  - run.dlang.io
  - Visual D
  - Acknowledgments
  - D Style
  - Glossary
  - Sitemap

Search
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

# core.attribute

This module contains UDA's (User Defined Attributes) either used in the runtime or special UDA's recognized by compiler.
License:
Boost License 1.0
Authors:
Jacob Carlborg

Source core/attribute.d

struct `selector`;
  Use this attribute to attach an Objective-C selector to a method.
  This is a special compiler recognized attribute, it has several requirements, which all will be enforced by the compiler:
  - The attribute can only be attached to methods or constructors which have Objective-C linkage. That is, a method or a constructor in a class or interface declared as

        extern(Objective-C)

    .
  ,
  - It cannot be attached to a method or constructor that is a template
  ,
  - The number of colons in the string need to match the number of arguments the method accept.
  ,
  - It can only be used once in a method declaration
  Examples:

      extern (Objective-C)
      class NSObject
      {
       this() @selector("init");
       static NSObject alloc() @selector("alloc");
       NSObject initWithUTF8String(in char* str) @selector("initWithUTF8String:");
       ObjcObject copyScriptingValue(ObjcObject value, NSString key, NSDictionary properties)
           @selector("copyScriptingValue:forKey:withProperties:");
      }

Copyright © 1999-2019 by the D Language Foundation | Page generated by Ddoc on Fri Oct 11 06:43:07 2019