Skip to main content

iOS Dev: 6 Useful Features of Xcode to Simplify iOS App Development

Xcode is an IDE used by iPhone developer or iPad app developer to do coding or developing iOS apps.
Xcode has many small and highly useful features which sometimes we are not aware of or it may happen that we may not be using those features at its optimum level in order to ease our iOS application development. For example : comments tag, code snippets, PO command and many more…
Here in this tutorial we will see 6 such useful features of Xcode which we can use during app development.

1. FIXME

This tag is used for reminding yourself of things that you need to fix back again at some later stage of iOS app programming.
FIXME Feature of Xcode

2. TODO

This tag is used for reminding yourself of things that you need to get back to at some point. Generally it is found at the top of the source file within the main comment block to remind us of features that need to update or add. Here you can see that.
TODO Feature of Xcode

3. #warning

It is used when you want to differentiate code into two category. One is for experiment and another is actual. For example.
Warning Feature of Xcode - 01
If we change 0(zero) to 1(one). Than warning is automatically removed as shown below.
Warning Feature of Xcode - 02
This technique will help you to ensure that you never release codes that includes / excludes code that shouldn’t / should be there.

4. po

This command is useful at debug time. In normal scenario, to print the value of a variable we have to move mouse pointer there and click on it and select print description print value of it. This is sometimes not programming friendly. With po command, this can be done easily and quickly. Lets see one example of it.
In this example, I have created one string named str and have set a value to it. Now to print that value without moving cursor over there, we  just have to write “po variable name” in output window and then press Enter. As shown below, you will get value stored inside variable.
PO Feature of Xcode

5. Code snippets

As a developer I observe that complex applications always need a well formatted code. So it is easy for other iOS developer to understand the code. So for this we will have to organize code in a standard format. But to organize code of larger applications, it will take some time. Xcode provides a functionality called snippets library. With the use of it we can organize code easily.
Code Snippets Feature of Xcode - 01
Xcode provides Code Snippets Library section where you can find all default code snippets provided by it. We can also create our custom code snippets as per our need and can add it over here for future use.  Here are some examples of using code snippets…
When we add new ViewController class. The default code is show as below.
Code Snippets Feature of Xcode - 02
I want to follow structure like all Memory related methods are first and view life cycle methods are last like below.
Code Snippets Feature of Xcode - 03
To reuse the same structure again and again we need add this code into snippets library. Now to add this code into snippets library, select text that you want to add like below,
Code Snippets Feature of Xcode - 04
Press and hold mouse left key than Drag it to code snippets library. After adding it to code snippets library, you will see a default name “My Code Snippet”. You can edit the name and also add description and shortcut key to it for your reference.
Code Snippets Feature of Xcode - 05
Code Snippets Feature of Xcode - 06
Lets see how we can use this newly created code snippet.
Now to use this newly created code snippet, Go back to Code Editor and just type “vlm”. You will find that Xcode will display an option for create code snippets with its title and summary as per shown below. Once you select it, you will get your defined structure with pragma.
Code Snippets Feature of Xcode - 07
It is also possible to highlight code snippet’s part which will be change after executing it. For example. Pragma mark name which is not common and can be changed as per requirement. For that we can use create code snippets with parameter as per below
Code Snippets Feature of Xcode - 08
Select this parameterised code and create code snippets with same process which we followed earlier. Now when you use this code snippets, You will see code with parameter as per below
Code Snippets Feature of Xcode - 09
Press Tab key, It will directly move you to that and change the name accordingly.

6. Find your File

To find file Quickly in a project press cmd + shift + o.
Open Quickly window will open. Write just name of your file that you are looking for and then press Enter. It will redirect you on that file.
Find Your File Feature of Xcode

These are the things that might be very useful in coding if you are iOS developer, so I thought to share it for your quick reference. Hope you will find this list useful, if there are any other useful features of Xcode, then we would love to hear from you on those features.
Reference article: Click Here
Thanks :)
Keep Coding :)
Vinay Mishra

Comments

Popular posts from this blog

WPF-MVVM: RelayCommand Implementation

In WPF if we are implementing MVVM pattern then we need to play with Command rather than Events. You can use ICommand interface to create each command class. Implementation of ICommand in a class gives you CanExecute(), Execute() methods which take part in the action performed by Command.   Rather than making Command Class for each Command we can implement a generic Relay Command to get Command. Below is a RelayCommand class that we will implement.   ///   <summary>      ///  To register commands in MMVM pattern      ///   </summary>      class   RelayCommands  :  ICommand     {          readonly   Action < object > _execute;          readonly   Predicate < object > _canExecute;  ...

iOS Dev: Encryption in Objective-C

Hello Friends: In this Article/Post, I introduced the one encryption technique in Objective-C.  Encryption Component Features in all  Symmetric Encryption: AES, Blowfish, Twofish, RC2, ARC4, DES, 3DES, PBES1, PBES2. Hash Algorithms :  SHA-1 , SHA256, SHA384, SHA512, MD2, MD4, MD5, HAVAL. Hash Algorithms: RIPEMD128, RIPEMD160, RIPEMD256, RIPEMD320. Encoding: Base64, hex, quoted-printable,  URL-encoding . HMAC with any supported hash algorithm: HMAC-MD5,  HMAC-SHA1 , etc. Password-based Key Derivation Functions: PBKDF1, PBKDF2 PKCS7 -- P7S and P7M creation, decryption, verification. Public key encryption/decryption with digital certificates. Digital signature creation/verification with digital certificates. Bzip2 in-memory compression. Encrypt / decrypt strings or byte data. Return encrypted data as Base64, quoted-printable, or hex-encoded strings. Hash strings or binary data using SHA1, MD2, MD5, HAVAL, SHA384, or SHA512. Public-key encryp...

iPhonegap: Developing a PhoneGap Application

Tutorial: Developing a PhoneGap Application Reference :  Here In this tutorial, you create a fully functional employee directory application with  PhoneGap . You will learn: How to use different local data storage strategies. How to use several PhoneGap APIs such as Geolocation, Contacts, and Camera. How to handle specific mobile problems such as touch events, scrolling, styling, page transitions, etc. How to build an application using a single page architecture and HTML templates. How to build (compile and package) an application for 6 platforms using  PhoneGap Build . To complete this tutorial, all you need is a code editor, a modern browser, and a connection to the Internet. A working knowledge of HTML and JavaScript is assumed, but you don’t need to be a JavaScript guru. Setting Up Download the assets for the workshop  here . Unzip the file anywhere on your file system. If your code editor allows you to “open a directory”, open the phonegap...