Tutorial by Examples: o

C++11 The alignas keyword can be used to force a variable, class data member, declaration or definition of a class, or declaration or definition of an enum, to have a particular alignment, if supported. It comes in two forms: alignas(x), where x is a constant expression, gives the entity the ali...
Installation Creating a new project Selecting Target and minimum version for your Application
When creating the project You should check "Include Unit Tests" in the project creation dialog. After creating the project If you missed checking that item while creating your project, you could always add test files later. To do so: 1- Go to your project settings in Xcode 2- Go to ...
To get started with unit testing, which will be done in the tests file and will be testing the View Controller and Storyboard, we should introduce these two files to the test file. Defining the View Controller Swift var viewController : ViewController! Introducing the Storyboard and initializi...
According to Apple: Test Methods A test method is an instance method of a test class that begins with the prefix test, takes no parameters, and returns void, for example, (void)testColorIsRed(). A test method exercises code in your project and, if that code does not produce the expected result, ...
To stop the Handler from execution remove the callback attached to it using the runnable running inside it: Runnable my_runnable = new Runnable() { @Override public void run() { // your code here } }; public Handler handler = new Handler(); // use 'new Handler(Looper.get...
In order to call a function through a function pointer, the function pointer's type must exactly match the function's type. Otherwise, the behaviour is undefined. Example: int f(); void (*p)() = reinterpret_cast<void(*)()>(f); p(); // undefined
To build up an expression like _ => _.Field == "VALUE" at runtime. Given a predicate _ => _.Field and a string value "VALUE", create an expression that tests whether or not the predicate is true. The expression is suitable for: IQueryable<T>, IEnumerable<T>...
Configuring the connection programmatically: var config = new ClientConfiguration { Servers = new List<Uri> { new Uri("http://localhost:8091/pools") }, BucketConfigs = new Dictionary<string, BucketConfiguration> ...
OOP - Object Oriented Programming is a vastly used programming paradigm in these days. In OOP, we model real world problems using Objects and there behaviors, in order to solve them, programmatically. There are four main OOP Concepts Inheritance Polymorphism Abstraction Encapsulation These...
To get versionName and versionCode of current build of your application you should query Android's package manager. try { // Reference to Android's package manager PackageManager packageManager = this.getPackageManager(); // Getting package info of this application PackageInfo...
foreach is unusual among the collections iterators in that it does not return a result. Instead it applies a function to each element that has only side effects. For example: scala> val x = List(1,2,3) x: List[Int] = List(1, 2, 3) scala> x.foreach { println } 1 2 3 The function sup...
System.assert can be used to check that a boolean expression evaluates to true: System.assert(Service.isActive()); System.assert(!Service.getItems().isEmpty(), 'items should not be empty'); System.assertEquals and System.assertNotEquals can be used to check equality of two values. The expected ...
In Object Oriented Design, objects receive messages and reply to them. In Ruby, sending a message is calling a method and result of that method is the reply. In Ruby message passing is dynamic. When a message arrives rather than knowing exactly how to reply to it Ruby uses a predefined set of rules...
class Example def example_method :example end def subexample_method :example end def not_missed_method :example end def method_missing name return :example if name == :missing_example_method return :example if name == :missing_subexample_method ...
Ruby moves up on ancestors chain of an object. This chain can contain both modules and classes. Same rules about moving up the chain apply to modules as well. class Example end module Prepended def initialize *args return super :default if args.empty? super end end module Fi...
The Continue operator works in For, ForEach, While and Do loops. It skips the current iteration of the loop, jumping to the top of the innermost loop. $i =0 while ($i -lt 20) { $i++ if ($i -eq 7) { continue } Write-Host $I } The above will output 1 to 20 to the console but miss...
Prior to Json.NET 4.5 dates were written using the Microsoft format: "/Date(1198908717056)/". If your server sends date in this format you can use the below code to serialize it to NSDate: Objective-C (NSDate*) getDateFromJSON:(NSString *)dateString { // Expect date in this format ...
This can be used in various chat applications, rss feeds, and social apps where you need to have latest feeds with timestamps: Objective-C - (NSString *)getHistoricTimeText:(NSDate *)since { NSString *str; NSTimeInterval interval = [[NSDate date] timeIntervalSinceDate:since]; if(in...
Using a file Swift let data = NSData(contentsOfFile: filePath) //assuming filePath is a valid path Objective-C NSData *data = [NSData dataWithContentsOfFile:filePath]; //assuming filePath is a valid path Using a String object Swift let data = (string as NSString).dataUsingEncoding(NSUTF8S...

Page 532 of 1038