Tutorial by Examples: add

You can add items to a user's Reading List in Safari by calling the addItem method on the SSReadingList singleton. let readingList = SSReadingList.default() readingList?.addItem(with: yourURL, title: "optional title", previewText: "optional preview text") The default Reading...
In the material design, a Floating action button represents the primary action in an Activity. They are distinguished by a circled icon floating above the UI and have motion behaviors that include morphing, launching, and a transferring anchor point. Make sure the following dependency is added to ...
Retrofit requests can be logged using an intercepter. There are several levels of detail available: NONE, BASIC, HEADERS, BODY. See Github project here. Add dependency to build.gradle: compile 'com.squareup.okhttp3:logging-interceptor:3.8.1' Add logging interceptor when creating Retrofit:...
Custom views can also take custom attributes which can be used in Android layout resource files. To add attributes to your custom view you need to do the following: Define the name and type of your attributes: this is done inside res/values/attrs.xml (create it if necessary). The following file...
nuget sources add -name feedname -source http://sourcefeedurl
To add a method to a button, first create an action method: Objective-C -(void)someButtonAction:(id)sender { // sender is the object that was tapped, in this case its the button. NSLog(@"Button is tapped"); } Swift func someButtonAction() { print("Button is tapped...
To add a header to a recyclerview with a gridlayout, first the adapter needs to be told that the header view is the first position - rather than the standard cell used for the content. Next, the layout manager must be told that the first position should have a span equal to the *span count of the e...
Swift let alert = UIAlertController(title: "Hello", message: "Welcome to the world of iOS", preferredStyle: UIAlertControllerStyle.alert) let defaultAction = UIAlertAction(title: "OK", style: UIAlertActionS...
The splice()method can be used to remove elements from an array. In this example, we remove the first 3 from the array. var values = [1, 2, 3, 4, 5, 3]; var i = values.indexOf(3); if (i >= 0) { values.splice(i, 1); } // [1, 2, 4, 5, 3] The splice() method can also be used to add elemen...
ALTER TABLE EMPLOYEES ADD pk_EmployeeID PRIMARY KEY (ID) This will add a Primary key to the table Employees on the field ID. Including more than one column name in the parentheses along with ID will create a Composite Primary Key. When adding more than one column, the column names must be separat...
// Calculate what day of the week is 36 days from this instant. System.DateTime today = System.DateTime.Now; System.TimeSpan duration = new System.TimeSpan(36, 0, 0, 0); System.DateTime answer = today.Add(duration); System.Console.WriteLine("{0:dddd}", answer);
Add days into a dateTime object. DateTime today = DateTime.Now; DateTime answer = today.AddDays(36); Console.WriteLine("Today: {0:dddd}", today); Console.WriteLine("36 days from today: {0:dddd}", answer); You also can subtract days passing a negative value: DateTime today...
double[] hours = {.08333, .16667, .25, .33333, .5, .66667, 1, 2, 29, 30, 31, 90, 365}; DateTime dateValue = new DateTime(2009, 3, 1, 12, 0, 0); foreach (double hour in hours) Console.WriteLine("{0} + {1} hour(s) = {2}", dateValue, hour, ...
string dateFormat = "MM/dd/yyyy hh:mm:ss.fffffff"; DateTime date1 = new DateTime(2010, 9, 8, 16, 0, 0); Console.WriteLine("Original date: {0} ({1:N0} ticks)\n", date1.ToString(dateFormat), date1.Ticks); DateTime date2 = date1.AddMilliseconds(1); Console....
Add years on the dateTime object: DateTime baseDate = new DateTime(2000, 2, 29); Console.WriteLine("Base Date: {0:d}\n", baseDate); // Show dates of previous fifteen years. for (int ctr = -1; ctr >= -15; ctr--) Console.WriteLine("{0,2} year(s) ago:{1:d}", ...
Properties can be added with categories using associated objects, a feature of the Objective-C runtime. Note that the property declaration of retain, nonatomic matches the last argument to objc_setAssociatedObject. See Attach object to another existing object for explanations. #import <objc/run...
Naming Convention Notifications are identified by global NSString objects whose names are composed in this way: Name of associated class + Did | Will + UniquePartOfName + Notification For example: NSApplicationDidBecomeActiveNotification NSWindowDidMiniaturizeNotification NSTextViewDidChange...
Suppose you have a simple Customer model: class Customer(models.Model): first_name = models.CharField(max_length=255) last_name = models.CharField(max_length=255) is_premium = models.BooleanField(default=False) You register it in the Django admin and add search field by first_name...
When filtering an email address filter_var() will return the filtered data, in this case the email address, or false if a valid email address cannot be found: var_dump(filter_var('[email protected]', FILTER_VALIDATE_EMAIL)); var_dump(filter_var('notValidEmail', FILTER_VALIDATE_EMAIL)); Results: ...
In order to define a Set of your own type you need to conform your type to Hashable struct Starship: Hashable { let name: String var hashValue: Int { return name.hashValue } } func ==(left:Starship, right: Starship) -> Bool { return left.name == right.name } Now you can cr...

Page 4 of 32