Tutorial by Examples: c

To convert a String to uppercase, use uppercaseString: NSString *myString = @"Emphasize this"; NSLog(@"%@", [myString uppercaseString]; // @"EMPHASIZE THIS" To convert a String to lowercase, use lowercaseString: NSString *myString = @"NORMALIZE this"; N...
Strings are compared for equality using isEqualToString: The == operator just tests for object identity and does not compare the logical values of objects, so it can't be used: NSString *stringOne = @"example"; NSString *stringTwo = [stringOne mutableCopy]; BOOL objectsAreIdentical =...
Modules can have a special variable named __all__ to restrict what variables are imported when using from mymodule import *. Given the following module: # mymodule.py __all__ = ['imported_by_star'] imported_by_star = 42 not_imported_by_star = 21 Only imported_by_star is imported when usi...
The checked out file will overwrite not yet commited changes you did in this file. This command will check out the file file.example (which is located in the directory path/to/) and overwrite any changes you might have made to this file. git checkout some-branch path/to/file some-branch can be ...
To develop an application for iOS, you should start with an application called Xcode. There are other alternative tools you can use, but Xcode is Apple's official tool. Note, however, that it only runs on macOS. The latest official version is Xcode 8.3.3 with Xcode 9 (currently in beta) due to be re...
There are two ways to connect to a MySQL/MariaDB server, depending on your infrastructure. Standard (TCP/IP) connection $dsn = 'mysql:dbname=demo;host=server;port=3306;charset=utf8'; $connection = new \PDO($dsn, $username, $password); // throw exceptions, when SQL error is caused $connection-...
Installing package manager Homebrew brew Paste that at a Terminal prompt. /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" Installing Xcode IDE Download it using link below or find it on Mac App Store https://developer.apple.com/down...
Objective-C CGRect myFrame = CGRectMake(0, 0, 320, 35) UIView *view = [[UIView alloc] initWithFrame:myFrame]; //Alternative way of defining the frame UIView *view = [[UIView alloc] init]; CGRect myFrame = view.frame; myFrame.size.width = 320; myFrame.size.height = 35; myFrame.origin.x = 0;...
Lists can be created in multiple ways. The recommended way is to use a List literal: var vegetables = ['broccoli', 'cabbage']; The List constructor can be used as well: var fruits = new List(); If you prefer stronger typing, you can also supply a type parameter in one of the following ways:...
Sets can be created via the constructor: var ingredients = new Set(); ingredients.addAll(['gold', 'titanium', 'xenon']);
Maps can be created in multiple ways. Using the constructor, you can create a new map as follow: var searchTerms = new Map(); Types for the key and value can also be defined using generics: var nobleGases = new Map<int, String>(); var nobleGases = <int, String>{}; Maps can othe...
The % wildcard appended to the beginning or end (or both) of a string will allow 0 or more of any character before the beginning or after the end of the pattern to match. Using '%' in the middle will allow 0 or more characters between the two parts of the pattern to match. We are going to use this...
When working with multi-module projects, it is helpful to centralize dependencies in a single location rather than having them spread across many build files, especially for common libraries such as the Android support libraries and the Firebase libraries. One recommended way is to separate the Gra...
Eloquent is the ORM built into the Laravel framework. It allows you to interact with your database tables in an object-oriented manner, by use of the ActiveRecord pattern. A single model class usually maps to a single database table, and also relationships of different types (one-to-one, one-to-man...
INSERT INTO `table_name` (`field_one`, `field_two`) VALUES ('value_one', 'value_two'); In this trivial example, table_name is where the data are to be added, field_one and field_two are fields to set data against, and value_one and value_two are the data to do against field_one and field_two resp...
INSERT INTO `table_name` (`index_field`, `other_field_1`, `other_field_2`) VALUES ('index_value', 'insert_value', 'other_value') ON DUPLICATE KEY UPDATE `other_field_1` = 'update_value', `other_field_2` = VALUES(`other_field_2`); This will INSERT into ta...
virtualenv is a tool to build isolated Python environments. This program creates a folder which contains all the necessary executables to use the packages that a Python project would need. Installing the virtualenv tool This is only required once. The virtualenv program may be available through yo...
Normally you would want to avoid using cursors as they can have negative impacts on performance. However in some special cases you may need to loop through your data record by record and perform some action. DECLARE @orderId AS INT -- here we are creating our cursor, as a local cursor and only a...
public class DatabaseHelper extends SQLiteOpenHelper { private static final String DATABASE_NAME = "Example.db"; private static final int DATABASE_VERSION = 3; // For all Primary Keys _id should be used as column name public static final String COLUMN_ID = "_id&q...
A struct can be used to bundle multiple return values: C++11 struct foo_return_type { int add; int sub; int mul; int div; }; foo_return_type foo(int a, int b) { return {a + b, a - b, a * b, a / b}; } auto calc = foo(5, 12); C++11 Instead of assignment to indi...

Page 69 of 826