Menu
  • HOME
  • TAGS

Swift Optional values out of an NSSet

swift,nsset,optional-values

that may be helpful: let set: NSSet = // ... for object : AnyObject in set { if let vertex = object as? Vertex { // do the main course } } ...

Photos API convert PHFetchResultChangeDetails indexes to NSMutableOrderedSet

ios,objective-c,nsset,photosframework,phphotolibrary

I've seemed to solve it (at least for now). I built my own removed, inserted, and changed indexes respectively, which isn't as efficient as the built in PHFetchResultChangeDetails ones, but I don't believe there's another way to do this. It takes about 4 seconds to chew through 2600 photos on...

Access all values inside an NSSet

ios,objective-c,nsdictionary,touchesbegan,nsset

You already have an NSSet of UITouch objects, and you have logged the properties on a UITouch object. So wether there is one UITouch object in the set or many you might fast enumerate through them with something like this: for (UITouch *touchObject in touches){ UIWindow *theWindow = touchObject.window; NSArray...

How to compare if a set of items exists in another set of items

ios,objective-c,arrays,cocoa,nsset

Your question isn't clear, but I am assuming that each element in your databaseArray is an array of NSStrings. The following method pulls each line in each element in databaseArray apart into separate words and verifies that at least one word from each line in the supplies list. - (NSArray...

NSSet: should I use float/double in NSSet?

ios,objective-c,osx,cocoa,nsset

there is float number precision problem when comparing float numbers. To be precise, only comparison for equality presents a problem. Unfortunately, that's the kind of comparison done by NSSet. So what happens when NSSet stocks NSValues that have float/double in it? It treats numbers that are really close to...

NSFetchRequest using IN statement ignores my order

objective-c,nspredicate,nsfetchrequest,nsset

It's very standard with SQL databases to not guarantee the order of returned rows unless you use the ORDER BY clause. Core Data is similar. If you want to guarantee the order you'll need to use a sort descriptor on your fetch request. Or, possibly, just sort them afterwards.

Find missing objects in NSSet

ios,objective-c,nsset

Use NSMutableSet and minusSet to remove elements in another set. The difference is what you're looking for.

Filter millions of strings and keep only unique ones Objective-C

objective-c,nsarray,nsset

Here a solution that is low cost for memory and cpu consumption : You can use a sqlite database : create a table with one column string as unique key that will receive each string you are parsing. During insertion of each string, if string is already in the table...

Best Practice for saving many to one in order using NSSet?

swift,ios8,order,nsset

Update your CoreData model to enable the "Ordered" attribute of the relationship. You'll also want to change the property declaration in your code to: @NSManaged var books: NSOrderedSet ...

ios - Subtract NSSet from other NSSet

ios,nspredicate,nsset

Your First Array is FirstMakes declaration is : NSArray *FirstMakes = @[@"Mercedes-Benz", @"BMW", @"Porsche", @"Opel", @"Volkswagen", @"Audi"]; Your second Array is SecondMakes declaration is : NSArray *SecondMakes = @[@"Mercedes-Benz", @"Porsche", @"Volkswagen"]; Filter `FirstMakes` to `SecondMakes` NSPredicate *beforeL = [NSPredicate predicateWithBlock: ^BOOL(id evaluatedObject, NSDictionary *bindings) { if ([SecondMakes containsObject:evaluatedObject]) { return...

Use NSScanner or NSRange for url to find NSSet objects

ios,string,webview,nsset,nsscanner

The following should be what you want: //External file links NSURL* externalURL = [request URL]; NSString *urlString = [externalURL absoluteString]; NSSet *supportedFileExtensions = [NSSet setWithObjects:@"mpeg", @"mpg", @"m1s", @"mpa", @"mp2", @"m2a", @"mp2v", @"mv2", @"m2s", @"avi", @"mov", @"qt", @"asf", @"asx", @"wmv", @"wma", @"wmx", @"rm", @"ra", @"ram", @"rmvb", @"mp4", @"3gp", @"3gpp", @"ogm", @"mkv",...

How to design “ordering” of objects with Core Data

ios,objective-c,oop,core-data,nsset

Use ordered relationship. It is mapped to NSOrderedSet.

Swift NSSet & CoreData

ios,core-data,swift,nsset

for aresponse in self.response.question.responses { // this next line throws an error var scoreVal = aresponse.score.integerValue The problem is that for aresponse in ... responses is iterating through an NSSet. Swift doesn't know what is in the NSSet, so it treats each value aresponse as an AnyObject, which has no...

Assigning data in a to-many relationship

ios,objective-c,core-data,nsset

You need to wrap your questionData inside a set. Since you only have one question at this time you can use [quizInfo setValue:[NSSet setWithObject:questionData] forKey:@"quizData"]; When you have more than one question you can either use: [quizInfo setValue:[NSSet setWithObjects:question1Data,question2Data,question3Data,nil] forKey:@"quizData"]; Or you could put your questions into an NSMutableArray and...

Getting unique value from core data

ios,objective-c,core-data,nsarray,nsset

You want to use CollectionOperators. NSLog(@"%@", [results valueForKeyPath:@"@distinctUnionOfObjects.students"]); ...

'NSSet?' does not contain a member called 'Generator'

ios,swift,nsset

The problem is you're trying to iterate on an optional set. You'll need to unwrap it first.

Set' does not have a member named 'allObjects'

swift,nsset

It looks as if your exampleSet is not an NSSet but a native Swift Set which was introduced with Swift 1.2 (compare http://stackoverflow.com/a/28426765/1187415). In that case you can convert it to an array simply with let array = Array(exampleSet) ...

NSOrderedSet not showing … order?

nsarray,nsset,nsorderedset

You are confusing "ordered" and "sorted". An array is an ordered collection, which means it has a first, second, third, up to a last element. A set or dictionary is an unordered collection, with no ordering of the elements. No first or last element. The NSOrderedSet combines the properties of...