Tutorial by Examples: c

To avoid verbose null checking, the ?. operator has been introduced in the language. The old verbose syntax: If myObject IsNot Nothing AndAlso myObject.Value >= 10 Then Can be now replaced by the concise: If myObject?.Value >= 10 Then The ? operator is particularly powerful when you...
Getting current date is very easy. You get NSDate object of current date in just single line as follows: Swift var date = NSDate() Swift 3 var date = Date() Objective-C NSDate *date = [NSDate date];
The number of seconds from the current date and time for the new date. Use a negative value to specify a date before the current date. For doing this we have a method named dateWithTimerIntervalSinceNow(seconds: NSTimeInterval) -> NSDate (Swift) or + (NSDate*)dateWithTimeIntervalSinceNow:(NSTime...
There are 4 methods for comparing dates: Swift isEqualToDate(anotherDate: NSDate) -> Bool earlierDate(anotherDate: NSDate) -> NSDate laterDate(anotherDate: NSDate) -> NSDate compare(anotherDate: NSDate) -> NSComparisonResult Objective-C - (BOOL)isEqualToDate:(NSDate *)anothe...
Get the description of an specific property in an object. var sampleObject = { hello: 'world' }; Object.getOwnPropertyDescriptor(sampleObject, 'hello'); // Object {value: "world", writable: true, enumerable: true, configurable: true}
Swift let alert = UIAlertController(title: "Hello", message: "Welcome to the world of iOS", preferredStyle: UIAlertControllerStyle.alert) let defaultAction = UIAlertAction(title: "OK", style: UIAlertActionS...
Compare method Either you implement a compare-method for your object: - (NSComparisonResult)compare:(Person *)otherObject { return [self.birthDate compare:otherObject.birthDate]; } NSArray *sortedArray = [drinkDetails sortedArrayUsingSelector:@selector(compare:)]; NSSortDescriptor NSS...
Custom Font Support Applications that want to use custom fonts can now include those fonts in their application bundle and register those fonts with the system by including the UIAppFonts key in their Info.plist file. The value of this key is an array of strings identifying the font files in the ...
We write custom action filters for various reasons. We may have a custom action filter for logging, or for saving data to database before any action execution. We could also have one for fetching data from the database and setting it as the global values of the application. To create a custom actio...
To get the timestamp in seconds Math.floor((new Date().getTime()) / 1000)
With UIAlertController, action sheets like the deprecated UIActionSheet are created with the same API as you use for AlertViews. Simple Action Sheet with two buttons Swift let alertController = UIAlertController(title: "Demo", message: "A demo with two buttons", preferredStyle...
getPreferences(int) returns the preferences saved by Activity's class name as described in the docs : Retrieve a SharedPreferences object for accessing preferences that are private to this activity. This simply calls the underlying getSharedPreferences(String, int) method by passing in this acti...
You may want to create a duplicate of a table: CREATE TABLE ClonedEmployees AS SELECT * FROM Employees; You can use any of the other features of a SELECT statement to modify the data before passing it to the new table. The columns of the new table are automatically created according to the selec...
To get your most recent stash after running git stash, use git stash apply To see a list of your stashes, use git stash list You will get a list that looks something like this stash@{0}: WIP on master: 67a4e01 Merge tests into develop stash@{1}: WIP on master: 70f0d95 Add user role to loca...
YourAsyncTask task = new YourAsyncTask(); task.execute(); task.cancel(); This doesn't stop your task if it was in progress, it just sets the cancelled flag which can be checked by checking the return value of isCancelled() (assuming your code is currently running) by doing this: class YourAsyn...
To spawn a new process in which you need unbuffered output (e.g. long-running processes which might print output over a period of time rather than printing and exiting immediately), use child_process.spawn(). This method spawns a new process using a given command and an array of arguments. The retu...
Classes can be created as follow: class InputField { int maxLength; String name; } The class can be instantiated using the new keyword after which the field values will be null by default. var field = new InputField(); Field values can then be accessed: // this will trigger the sette...
<p contenteditable>This is an editable paragraph.</p> Upon clicking on the paragraph, the content of it can be edited similar to an input text field. When the contenteditable attribute is not set on an element, the element will inherit it from its parent. So all child text of a conte...
You can compare BigIntegers same as you compare String or other objects in Java. For example: BigInteger one = BigInteger.valueOf(1); BigInteger two = BigInteger.valueOf(2); if(one.equals(two)){ System.out.println("Equal"); } else{ System.out.println("Not Equal"...
{ "name": "my-project", "version": "0.0.1", "description": "This is a project.", "author": "Someone <[email protected]>", "contributors": [{ "name": "Som...

Page 114 of 826