Tutorial by Examples

// *** Find movies except given ids *** NSPredicate *filterByNotInIds = [NSPredicate predicateWithFormat:@"NOT (self.id IN %@)",@[@"7CDF6D22-8D36-49C2-84FE-E31EECCECB79", @"7CDF6D22-8D36-49C2-84FE-E31EECCECB76"]]; NSLog(@"Filter movies except given Ids : %@"...
// *** Find all the objects which is of type movie, Both the syntax are valid *** NSPredicate *filterByMovieType = [NSPredicate predicateWithFormat:@"self.isMovie = %@",@1]; // OR //NSPredicate *filterByMovieType = [NSPredicate predicateWithFormat:@"self.isMovie = %@",[NSNumbe...
// *** Find Distinct object ids of array *** NSLog(@"Distinct id : %@",[array valueForKeyPath:@"@distinctUnionOfObjects.id"]);
// *** Find movies with specific ids *** NSPredicate *filterByIds = [NSPredicate predicateWithFormat:@"self.id IN %@",@[@"7CDF6D22-8D36-49C2-84FE-E31EECCECB79", @"7CDF6D22-8D36-49C2-84FE-E31EECCECB76"]]; NSLog(@"Filter By Ids : %@",[array filteredArrayUsingP...
// *** Case Insensitive comparison with exact title match *** NSPredicate *filterByNameCIS = [NSPredicate predicateWithFormat:@"self.title LIKE[cd] %@",@"Tom and Jerry"]; NSLog(@"Filter By Name(CIS) : %@",[array filteredArrayUsingPredicate:filterByNameCIS]);
// *** Case sensitive with exact title match *** NSPredicate *filterByNameCS = [NSPredicate predicateWithFormat:@"self.title = %@",@"Tom and Jerry"]; NSLog(@"Filter By Name(CS) : %@",[array filteredArrayUsingPredicate:filterByNameCS]);
// *** Case Insensitive comparison with matching subset *** NSPredicate *filterByName = [NSPredicate predicateWithFormat:@"self.title CONTAINS[cd] %@",@"Tom"]; NSLog(@"Filter By Containing Name : %@",[array filteredArrayUsingPredicate:filterByName]);
An enumeration is a user-defined data type consists of integral constants and each integral constant is given a name. Keyword enum is used to define enumerated data type. If you use enum instead of int or string/ char*, you increase compile-time checking and avoid errors from passing in invalid con...
There are several possibilities and conventions to name an enumeration. The first is to use a tag name just after the enum keyword. enum color { RED, GREEN, BLUE }; This enumeration must then always be used with the keyword and the tag like this: enum color chosenColor = RE...
There are times in which it is desirable to consolidate factor levels into fewer groups, perhaps because of sparse data in one of the categories. It may also occur when you have varying spellings or capitalization of the category names. Consider as an example the factor set.seed(1) colorful <...
To iterate over several generators in parallel, use the zip builtin: for x, y in zip(a,b): print(x,y) Results in: 1 x 2 y 3 z In python 2 you should use itertools.izip instead. Here we can also see that the all the zip functions yield tuples. Note that zip will stop iterating as soon...
C++17 C++17 introduces std::string_view, which is simply a non-owning range of const chars, implementable as either a pair of pointers or a pointer and a length. It is a superior parameter type for functions that requires non-modifiable string data. Before C++17, there were three options for this: ...
NSString *pathToPlist = [[NSBundle mainBundle] pathForResource:@"plistName" ofType:@"plist"]; NSDictionary *plistDict = [[NSDictionary alloc] initWithContentsOfFile:pathToPlist];
It is usually not a good idea to mix signed and unsigned integers in arithmetic operations. For example, what will be output of following example? #include <stdio.h> int main(void) { unsigned int a = 1000; signed int b = -1; if (a > b) puts("a is more than b&quot...
public bool IsTypeNullable<T>() { return Nullable.GetUnderlyingType( typeof(T) )!=null; }
A common usage scenario that this feature really helps with is when you are looking for an object in a collection and need to create a new one if it does not already exist. IEnumerable<MyClass> myList = GetMyList(); var item = myList.SingleOrDefault(x => x.Id == 2) ?? new MyClass { Id = 2...
// define url let url = NSURL(string: "https://urlToGet.com") //create a task to get data from a url let task = NSURLSession.sharedSession().dataTaskWithURL(url!) { /*inside this block, we have access to NSData *data, NSURLResponse *response, and NSError...
This example shows how to use the default logging api. import java.util.logging.Level; import java.util.logging.Logger; public class MyClass { // retrieve the logger for the current class private static final Logger LOG = Logger.getLogger(MyClass.class.getName()); pub...
There are multiple ways to set a key's object in an NSDictionary, corresponding to the ways you get a value. For instance, to add a lamborghini to a list of cars Standard [cars setObject:lamborghini forKey:@"Lamborghini"]; Just like any other object, call the method of NSDictionary th...
There are multiple ways to get an object from an NSDictionary with a key. For instance, to get a lamborghini from a list of cars Standard Car * lamborghini = [cars objectForKey:@"Lamborghini"]; Just like any other object, call the method of NSDictionary that gives you an object for a ...

Page 247 of 1336