nsset

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

人走茶凉 提交于 2019-12-10 10:18:52
问题 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

Combinations of different NSArray objects

泄露秘密 提交于 2019-12-09 01:35:02
问题 I want to find the combinations of the elements in diffrent arrays . Let say I've three NSArray objects as: NSArray *set1 = [NSArray arrayWithObjects:@"A",@"B",@"C", nil]; NSArray *set2 = [NSArray arrayWithObjects:@"a",@"b", nil]; NSArray *set3 = [NSArray arrayWithObjects:@"1",nil]; Now the required answers is following arrays NSArray *combinations = [{A},{B},{C},{a},{b},{1},{A,a},{A,b},{A,1},{B,a},{B,b},{B,1},{a,1},{b,1},{A,a,1},{A,b,1},{B,a,1},{B,b,1},{C,a,1},{C,b,1}]; Edit Currently I've

How get objects from one array with same properties of other?

元气小坏坏 提交于 2019-12-08 06:03:44
问题 For example: I have two NSMutableArray . One @[1,2,3,4,5,6,7] . Other have objects like @[ @{@idObjectToSearch":1, @"name":@"aaaaa", @"surname": @"bbbbb"}, @{@idObjectToSearch":2, @"name":@"aaaaa", @"surname": @"ccccc"}, ... @{@idObjectToSearch":100, @"name":@"aaaaa", @"surname": @"cccdcd"} ]; So how I could extract needed objects from second array more effective way? 回答1: You need to use NSPredicate with your second array. NSPredicate *predicate = [NSPredicate predicateWithFormat:@

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

空扰寡人 提交于 2019-12-07 16:57:18
问题 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

Swift NSSet & CoreData

时光怂恿深爱的人放手 提交于 2019-12-07 03:10:06
问题 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:

Swift and CoreData, problems with relationship (NSSet) - [NSSet intersectsSet:]: set argument is not an NSSet

只谈情不闲聊 提交于 2019-12-06 19:00:09
问题 I've been trying to get my head around adding objects in relationships using CoreData and Swift. I am at a loss, I do not understand why my code does not work. I am trying to add an "Event" to a "Team". I can not find the difference between accepted answers (that should work), and my code (that does not). Teams.swift: import Foundation import CoreData class Teams: NSManagedObject { @NSManaged var teamName: String @NSManaged var matches: NSSet } extension Teams { func addEventToTeam(event

How get objects from one array with same properties of other?

落爺英雄遲暮 提交于 2019-12-06 14:36:28
For example: I have two NSMutableArray . One @[1,2,3,4,5,6,7] . Other have objects like @[ @{@idObjectToSearch":1, @"name":@"aaaaa", @"surname": @"bbbbb"}, @{@idObjectToSearch":2, @"name":@"aaaaa", @"surname": @"ccccc"}, ... @{@idObjectToSearch":100, @"name":@"aaaaa", @"surname": @"cccdcd"} ]; So how I could extract needed objects from second array more effective way? You need to use NSPredicate with your second array. NSPredicate *predicate = [NSPredicate predicateWithFormat:@"idObjectToSearch IN %@", firstArray]; //In above predicate instead of passing `1` you need to pass object from first

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

一世执手 提交于 2019-12-06 05:15:19
问题 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 =

NSSet use predicate to return objects matching given class

一曲冷凌霜 提交于 2019-12-05 22:17:34
问题 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? 回答1: You can use a block-based predicate like this: NSSet *yourSet = ...; NSPredicate *pred = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary

How to compare two NSSets based on attributes of objects?

本秂侑毒 提交于 2019-12-05 21:23:36
I have two nssets. nsset1: person.id = 1, person.id = 2, person.id = 3 nsset2: person.id = 1, person.id = 2 Results should be: nsset1 - nsset2: person (with id 3) nsset2 - nsset1: null These objects with the same id in those two sets are different objects, so I couldn't simply do minusSet. I want to do something like: nsset1: person.id = 1, person.id = 2, person.id = 3 nsset2: person.id = 4, person.id = 5 Results should be like this: nsset1 - nsset2: person (id 1), person (id 2), person (id 3) nsset2 - nsset1: person (id 4), person (id 5) What is the best way to do this? You should try