Usage of variable templates (variable template) in Xcode

Source: Internet
Author: User

Panda Pig • Patty original or translated works. Welcome reprint, Reprint please indicate the source.
If you feel that the writing is not good please more advice, if you feel good please support a lot of praise. Thank you! Hopy;)

You may often write small snippets of code that naturally involve some key variables. You'll put these snippets on the web, like GitHub, as an example.

However, the problem is that the variables in the code snippet above will vary from one user to another, depending on the system. If you work here, it may be ineffective in others.

As an inappropriate example, one of the variables is the key ID of your server:

NSString *keyID = @"12345678"

Of course, if you set the secret key ID of your home server so simple, it's estimated that you'll be off work soon;), the point here is that when someone tests, it's obviously wrong to use the key ID value above.

To avoid the possibility of the above error, you can certainly write a comment like this:

//注意!以下变量的值必须在你的环境中做相应修改NSString *keyID = @"12345678"

But it looks like the job is not beautiful ... Fortunately, Xcode provides us with a special variant of the template (variable templates) syntax that works well for this situation, which we can write:

*keyID = <# 你们家服务器上的keyID #>

You might be dismissive of that, but let's look at the results shown in Xcode:

Is it simple? Sometimes small changes can change the world;)

Usage of variable templates (variable template) in Xcode

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.