nsset

Why does [NSSet containsObject] fail for SKNode members in iOS8?

老子叫甜甜 提交于 2019-12-05 19:52:23
Two objects are added to an NSSet , but when I check membership, I can't find one of them. The test code below worked fine in iOS7 but fails in iOS8. SKNode *changingNode = [SKNode node]; SKNode *unchangingNode = [SKNode node]; NSSet *nodes = [NSSet setWithObjects:unchangingNode, changingNode, nil]; changingNode.position = CGPointMake(1.0f, 1.0f); if ([nodes containsObject:changingNode]) { printf("found node\n"); } else { printf("could not find node\n"); } Output: could not find node What happened between iOS7 and iOS8, and how can I fix it? Karl Voskuil SKNode 's implementations of isEqual

“Error: this process has called an NSArray-taking method…” when iCloud pushes managed objects

无人久伴 提交于 2019-12-05 18:35:05
For every managed object that is sent via iCloud update, this warning/error is sent to the console: *** ERROR: this process has called an NSArray-taking method, such as initWithArray:, and passed in an NSSet object. This is being worked-around for now, but will soon cause you grief. My managed objects are Clients and have a one to many relationship with assessments as shown below. class Client: NSManagedObject { //other NSManaged vars are here @NSManaged var assessment: NSOrderedSet } Judging by the timing of this error (during ubiquitous updates) and the fact that this is my only use of NSSet

Swift NSSet & CoreData

旧巷老猫 提交于 2019-12-05 08:20:27
I am trying to move an objective C & CoreData app to Swift and iOS and hit a brick wall with iterating through NSSet objects: Xcode has generated these classes: class Response: NSManagedObject { @NSManaged var responseText: String @NSManaged var score: NSNumber @NSManaged var answers: NSSet @NSManaged var question: Question } class Question: NSManagedObject { @NSManaged var questionText: String @NSManaged var questionType: String @NSManaged var qualifier: Qualifier @NSManaged var responses: NSSet } then in the 3rd class I am adding a method that needs to iterate though an NSSet.. class Answer:

CLLocationManager monitoredRegions (NSSet) is not correct, or maybe something else?

早过忘川 提交于 2019-12-05 03:20:54
问题 I want to check every time the user passes a store from an array of stores, I have more than 20 stores so I wrote a function that finds the 20 closest stores to the user’s location and monitors them. The list being updated on locationManager: didUpdateLocations , I also replace the old 20 monitored regions with the new 20 closest stores location. The problem is that locationManager: didEnterRegion isn’t being called regularly when the user enters a region. I’ve also noticed that when I check

NSPredicate find object with attribute in NSSet

拟墨画扇 提交于 2019-12-04 22:09:48
问题 I have an NSMangedObject that contains NSSet of other NSManagedObjects . I need to check if these objects has an value in NSSet and then return them. I use MagicalRecord for fetching data. So I need something like this: NSPredicate *predicate = [NSPredicate predicateWithFormat:@"stringObjects contains %@", string]; So if NSSet stringObjects contains some string that I am looking for so then return object I have requested. One note here: stringObjects (name just for example it represent my

Is NSSet faster than NSArray?

时光总嘲笑我的痴心妄想 提交于 2019-12-04 18:46:08
i am new to iOS. Anyone know if NSSet are faster than NSArray ? Why wouldn't I always just use an NSArray ? Anyone explain me difference between NSSet and NSArray ? Vijay-Apple-Dev.blogspot.com NSSet is used to have unique objects. NSArray may have duplicate objects. NSSet is an unordered collection. NSArray is an ordered collection. NSArray is faster than NSSet for simply holding and iterating. As little as 50% faster for constructing and as much as 500% faster for iterating. if you only need to iterate contents, don't use an NSSet. When the order of the items in the collection is not

How do I get unique values from an array

倾然丶 夕夏残阳落幕 提交于 2019-12-04 11:47:20
Please note this is for OSX, not for iOS. I have looked and tried some solutions in other SO questions, but none seem to work for me, hence this: I want to get a unique set of years out of an array. My code is this: NSMutableArray * unique = [NSMutableArray array]; NSMutableSet * processed = [NSMutableSet set]; for (yearString in yearStringArray) { if (![processed containsObject:yearString] == NO) { [unique addObject:yearString]; } [processed addObject:yearString]; } NSLog(@"unique: %@",unique ); NSLog(@"processed: %@",processed ); }]; The console returns: unique: ( ( 1941, 1942, 1943, 1945,

How to check if an objects is inside of a NSSet of objects by using predicateWithFormat in CoreData?

和自甴很熟 提交于 2019-12-04 11:07:16
In my iPhone app, I try to have a TableViewController to display a list of photos those share one same tag (currentTag in code below). Photo and tag are "many to many" relationship in database. Each photo has an attribute named "tags", which type is NSSet. Each tag has an attribute named "photos", which type is NSSet, too. Tag has an attribute called "name". I'm trying to do the following code: NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Photo"]; request.predicate = [NSPredicate predicateWithFormat:@"tags contains %@",currentTag]; The problem is I can't do many

NSSet use predicate to return objects matching given class

浪子不回头ぞ 提交于 2019-12-04 04:45:31
Let's say I have an NSSet that contains a collection of objects of type id<Shape> . . . of which there are CircleShape, SquareShape, HexagonalShape instances put into it (not the real protocol or class names) . . is it possible to use a predicate or another single line of code to return all of the instances of CircleShape? You can use a block-based predicate like this: NSSet *yourSet = ...; NSPredicate *pred = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) { return [evaluatedObject isKindOfClass:[CircleShape class]]; }]; NSSet *filteredSet = [yourSet

CLLocationManager monitoredRegions (NSSet) is not correct, or maybe something else?

拥有回忆 提交于 2019-12-03 17:40:39
I want to check every time the user passes a store from an array of stores, I have more than 20 stores so I wrote a function that finds the 20 closest stores to the user’s location and monitors them. The list being updated on locationManager: didUpdateLocations , I also replace the old 20 monitored regions with the new 20 closest stores location. The problem is that locationManager: didEnterRegion isn’t being called regularly when the user enters a region. I’ve also noticed that when I check the locationManager.monitoredRegions NSSet the regions there are wrong for some reason (I checked it