Dismissing The UITextField Keyboard

ios-keyboardLet’s say you are designing an iOS application which takes user input using a text field. When you add a text field to your storyboard and run your application, you will see that when you tap on the text field, the keyboard pops up automatically. But when you tap the return key, they keyboard doesn’t go away. As it turns out, the popping up of the keyboard is taken care of when you add the UITextField, but dismissing the keyboard is up to you. Here’s how you make it go away after you are done taking the input from the user:   Continue reading “Dismissing The UITextField Keyboard”

iOS App: Separator Lines And Back Button In Master-Detail Application

mainWhen you create a master-detail application in iOS, a few things appear by default. If you notice it, you will see that the empty cells are separated by lines. But we want the separator lines to appear for items that are there in the table. Also, you will notice that the back button in the detail view contains the title by default. What if we want it to say something else? Perhaps not say anything at all. How do we do it?   Continue reading “iOS App: Separator Lines And Back Button In Master-Detail Application”

C++ Vector Memory Release

mainWhen you use C++ STL, it takes care of freeing up memory after a variable goes out of scope. But let’s say you have some code that needs the memory to be freed up immediately. This can happen under many circumstances when you are working under constrained resources. One of the more popular STL containers is ‘vector’. Let’s say you have declared a bunch of those in your code and you want to free them up manually. You may think that using clear() on that vector might take care of the situation, but it doesn’t. You can call clear(), and it will destroy all the objects, but it will not free up the memory. So how do we do it?   Continue reading “C++ Vector Memory Release”

Package OpenCV not found? Let’s Find It.

mainOpenCV has been refined over the years and installing it has become way more user-friendly now. If has been ported to many platforms and you don’t need an IDE to use it. There are many different ways in which you can install it and use it in your existing code. But sometimes, when people try to do different things with it, they run into problems. This post deals with one such problem. When you write code that uses OpenCV, you need to tell your compiler where it is. The reason for this is that this location will contains all the libraries and binaries necessary for the header files to work in your code. If you don’t specify this, you will encounter the following error:   Continue reading “Package OpenCV not found? Let’s Find It.”

Understanding Recursion: Part 4/4

mainIn the previous posts, we understood the basics of recursion, we discussed what happens when a recursive call is made and we saw some recursive code. But all that was from a programmer’s perspective. We looked at how we would see it. In this post, we will talk about about recursion from a machine’s perspective. We will see what happens inside when a recursive call is made. Don’t worry if you are not a hardcore coder, we will not be using too much jargon here. You will still be able to understand what we are about to discuss.   Continue reading “Understanding Recursion: Part 4/4”

Understanding Recursion: Part 3/4

recursive treeIn the previous post, we discussed about how we can deconstruct a programming problem to use recursion to our advantage. We will continue to discuss about programming in this post as well. If you are not prepared to look at code, you may want to skip this post and proceed to the next one in the series. If not, continue reading! Let’s continue to talk about trees then. By now, you understand enough about trees for me to not discuss the basics. If you want a refresher on trees, please read my previous post. In this post, we will look at some common recursive programming problems. You will see the problem and the recursive code to solve it, but not the explanation. We have already discussed how to understand a recursive function in full depth. It’s up to you to understand what’s happening inside these functions here.   Continue reading “Understanding Recursion: Part 3/4”

Understanding Recursion: Part 2/4

programming kidIn the previous post, we discussed about the general nature of recursion and recursive programming. We looked at a simple piece of code to understand how recursion happens under the hood. This post delves a bit deeper into recursive programming. Now that we understand recursion, how do we apply it to a real programming problem? We need to understand how we can deconstruct a programming problem so that we can use recursion. Figuring this part out can get tricky sometimes! It’s easier for some problems, but not so much for a few others. In this post, we will look at an abstract data type and see how we use recursion to our advantage. Let’s get out hands dirty, shall we?   Continue reading “Understanding Recursion: Part 2/4”

Understanding Recursion: Part 1/4

part 1Remember the initial days when you were forced to learn recursive programming? And how you were thankful that it’s all over and you don’t have to deal with the whole thing anymore? Well, why do you think that is? Recursion is not all that bad! A lot of beginners who start out with programming somehow end up hating recursion. The main reason is that people don’t really understand how to deconstruct a given problem to make it suitable for recursion. Recursive code, by itself, is nice and small. But understanding what exactly is the recursive part can be pretty confusing. If used correctly, recursion can be one of the best weapons in your programming arsenal. Let’s see what’s beneath all this!   Continue reading “Understanding Recursion: Part 1/4”

Random Number Generators In Programming

If you have fiddled around enough with C/C++/Objective-C, you must have noticed that if you use rand() function on its own, it gives the exact same numbers every time. Now how is that possible? Isn’t rand() function supposed to generated completely random numbers in a given range? The reason for this has something to do with the seed value. If you use the same seed value every time, then you will get the same numbers.   Continue reading “Random Number Generators In Programming”

Expected Expression Error

You tried to declare a variable after a ‘case’ statement and it showed an error. If that’s the reason you are here, then read on. This must actually be surprising to most people familiar with C++ programming because C++ allows us to declare variables almost anywhere in the program. In fact, declaring them close the first use is actually a good practice. So why can’t you declare variables after a case label in a switch statement?   Continue reading “Expected Expression Error”