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”

EXC_BAD_ACCESS Problem In Objective-C

EXC_BAD_ACCESS memeSo you finally stumbled upon this error. If you have been working with Objective-C, this is bound to happen. When you release the memory of an object that has already been released, and then try to go back to your previous UIViewController, you will encounter this error. One of the possible reasons could be that you must be using Automatic Reference Counting (ARC) in your project. ARC was a new feature introduced in iOS 5.0 to take care of memory management. This is a very useful feature, but it can also cause errors if you don’t understand what’s happening under the hood.   Continue reading “EXC_BAD_ACCESS Problem In Objective-C”