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;  ...

.Net List with Changed event

Sometimes we need a List which can notify user when an item is added. Here is the way that you can implement a generic ArrayList which notifies user at the time of an element is added.   using  System; using  System.Collections; namespace  ArchiveData.Logging {    // A delegate type for hooking up change notifications.    public   delegate   void   ChangedEventHandler ( object  sender,  EventArgs  e);    public   class   ListWithChangedEvent  :  ArrayList   {      // An event that clients can use to be notified whenever the      // elements of the list change.      public   event   ChangedEventHandler  Changed;      public   object  NewlyAddedItem {...

What is DispatcherTimer in wpf?

DispatcherTimer When you want to set a timer working with GUI, you always come across threading problem. The problem is that if you want to send some changes to UI that is constantly/continuously changing then that will make your UI unresponsive or in other words it will hang your UI.   To overcome from this situation, WPF gives us DispatcherTimer threading functionality that will take care of such continuously changing processing on UI thread and that will not hang your UI. We can accomplish same scenario in Win Form , through System.Windows.Forms.Timer and in WPF it is System.Windows.Threading.DispatcherTimer .   Difference between DispatcherTimer and Regular timer (System.Timers.Timer) DispatcherTimer is the regular timer. It fires its Tick event on the UI thread, you can do anything you want with the UI. System.Timers.Timer is an asynchronous timer, its Elapsed event runs on a thread pool thread. You have to be very careful in your event handler...