Tutorial by Examples: c

You can create your own queue using dispatch_queue_create Objective-C dispatch_queue_t queue = dispatch_queue_create("com.example.myqueue", DISPATCH_QUEUE_SERIAL); Swift // Before Swift 3 let queue = dispatch_queue_create("com.example.myqueue", DISPATCH_QUEUE_SERIAL) // ...
You can add an image to a view's layer simply by using its contents property: myView.layer.contents = UIImage(named: "star")?.CGImage Note that the UIImage needs to be converted to a CGImage. If you wish to add the image in its own layer, you can do it like this: let myLayer = CA...
Basics There are a number of different transforms you can do on a layer, but the basic ones are translate (move) scale rotate To do transforms on a CALayer, you set the layer's transform property to a CATransform3D type. For example, to translate a layer, you would do something like this:...
You can test that a function throws an exception with the built-in unittest through two different methods. Using a context manager def division_function(dividend, divisor): return dividend / divisor class MyTestCase(unittest.TestCase): def test_using_context_manager(self): ...
Xposed is a framework that allows you to hook method calls of other apps. When you do a modification by decompiling an APK, you can insert/change commands directly wherever you want. However, you will need to recompile/sign the APK afterwards and you can only distribute the whole package. With Xpose...
In an iOS app, your user interface can take on one of a few different general shapes and sizes. These are defined using size classes, which are available through a view or view controller's trait collection. Apple defines two size classes: regular and compact. Each of these size classes are availab...
Making an app adaptive – that is, responding to size class changes by changing your layout – often involves lots of help from the Auto Layout system. One of the primary ways apps become adaptive is by updating the active Auto Layout constraints when a view's size class changes. For example, conside...
void alertDialogDemo() { // get alert_dialog.xml view LayoutInflater li = LayoutInflater.from(getApplicationContext()); View promptsView = li.inflate(R.layout.alert_dialog, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( ...
Character literals are a special type of integer literals that are used to represent one character. They are enclosed in single quotes, e.g. 'a' and have the type int. The value of the literal is an integer value according to the machine's character set. They do not allow suffixes. The L prefix bef...
Suppose we want to have a route that allows an unbound number of segments like so: http://example.com/Products/ (view all products) http://example.com/Products/IT http://example.com/Products/IT/Laptops http://example.com/Products/IT/Laptops/Ultrabook http://example.com/Products/IT/Laptops/Ult...
The following is a list of tips for those who are looking to contribute to the PHP manual: Follow the manual's style guidelines. Ensure that the manual's style guidelines are always being followed for consistency's sake. Perform spelling and grammar checks. Ensure proper spelling and grammar is ...
Sometimes the shell prompt doesn't display the name of the virtual environment and you want to be sure if you are in a virtual environment or not. Run the python interpreter and try: import sys sys.prefix sys.real_prefix Outside a virtual, environment sys.prefix will point to the system p...
There are a few ways to use functions. Calling a function with an assignment statement DECLARE x NUMBER := functionName(); --functions can be called in declaration section BEGIN x := functionName(); END; Calling a function in IF statement IF functionName() = 100 THEN Null; EN...
When executing a Bash script, parameters passed into the script are named in accordance to their position: $1 is the name of the first parameter, $2 is the name of the second parameter, and so on. A missing parameter simply evaluates to an empty string. Checking for the existence of a parameter can...
Interfaces can seem abstract until you seem them in practice. The IComparable and IComparable<T> are great examples of why interfaces can be helpful to us. Let's say that in a program for a online store, we have a variety of items you can buy. Each item has a name, an ID number, and a price. ...
var xhr = $.ajax({ type: "POST", url: "some.php", data: "name=John&location=Boston", success: function(msg){ alert( "Data Saved: " + msg ); } }); //kill the request xhr.abort()
There are two possible ways of including LaTeX preamble commands (e.g. \usepackage) in a RMarkdown document. 1. Using the YAML option header-includes: --- title: "Including LaTeX Preample Commands in RMarkdown" header-includes: - \renewcommand{\familydefault}{cmss} - \usepacka...
A bibtex catalogue cna easily be included with the YAML option bibliography:. A certain style for the bibliography can be added with biblio-style:. The references are added at the end of the document. --- title: "Including Bibliography" author: "John Doe" output: pdf_documen...
To include a database in your app, you typically derive a class from SQLiteOpenHelper: public class HelloDBHelper extends SQLiteOpenHelper { private static final int DATABASE_VERSION = 1; private static final int DATABASE_NAME = "hello"; HelloDBHelper(Context context) {...
A simple POST request with authentication data is demonstrated below, note that the username and password field will vary depending on the website: final String USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"; ...

Page 391 of 826