nsset

What is the most efficient way to sort an NSSet?

What's the most efficient way to sort objects in an NSSet/NSMutableSet based on a property of the objects in the set? Right now the way I am doing it is by iterating through each object, add them to a NSMutableArray, and sort that array with NSSortDescriptor. ...

Cocoa-Touch: Quick way to sum a property in all objects within an NSSet?

I may very well be confusing this with the Cocoa (Mac OS X) side of things so it may not exist in Cocoa-Touch...but I thought there was a way to quickly ask a NSSet to poll its members and return a sum of say an NSInteger property in each of its objects? Closest I can find is objectEnumerator whereby I suppose I could rifle through each...

How to determine if an NSSet contains touches for a specific control?

This may seem like a stupid question, but what message do i send to the NSSet class to determine how many times a particular control has been tapped? ...

How to display an NSSet in a UITableView?

How would you proceed to display the content of an NSSet in a UITableView? As you know, the table view will ask for the element at a given row, but since the NSSet elements aren't ordered, this doesn't mix well. My current solution is to iterate through the NSSet until I reach the element at a given index, but this really doesn't feel ...

NSManagedObject relationship NSSet iteration

Hi, I have a subclassed NSManagedObject (ObjectA) which has a relationship one-to-may to another subclassed NSManagedObject (ObjectB). I get the ObjectB NSSet from ObjectA's generated method. I want to determine if an ObjectB with a given 'name' exists in the returned NSSet (e.g. ObjectB.name == "xxx"). What is the most efficient way ...

Getting the Minimum Value of an Attribute in a NSSet Made from a One-to-Many Relationship in Core Data

I have several objects set up in Core Data, one of which is "Deck" and one of which is "Card". "Cards" have several numbered relationships, including "id". "Deck" has a one-to-many relationship with cards. What's the best way to find the Card in a Deck that has the minimum value to some numbered attribute, such as id? Clearly I can get...

Cocoa: Any downside to using NSSet as key in NSMutableDictionary?

Is there any downside to using NSSet as key in NSMutableDictionary, any gotchas to be aware of, any huge performance hits? I think keys are copied in Cocoa containers, does it mean NSSet is copied to dictionary? Or is there some optimization that retains the NSSet in this case? Related to http://stackoverflow.com/questions/1863061/can-...

How do I put objects in an NSArray into an NSSet?

Hi all, I have some NSDictionary objects stored in an NSArray called telephoneArray. I fetch the values for the key number and then replace the NSDictionary I've just read with a new object at the same index in the array. I then want to put these new objects into an NSSet. How can this be achieved? See my unsuccessful attempt below. ...

Change an NSSet of NSNumber into an NSSet of int

Hi everyone, I'm using the data with core data and get an NSSet of NSNumber... my question is how can I do to change easily all the objects into int values? or can I directly get the int values from the database? Thanks ...

NSSet to NSData, then back out again, for GameKit?

Hi guys, I'm trying to do some image edit syncing between two of the same app running on different iPhones. I would like to send an NSSet * from one device to another (which I imagine involves encapsulating in NSData) then decrypting this back to an NSSet, then using it in a touchesMoved type of function. Is this feasible, or should I w...

Looking for an elegant way to store one-to-many relationship in coredata when order is important

I've been trying to come up with a way to solve my problem, but every solution I can think of is messy and makes me want to retch. I have a one-to-many relationship, consisting of a Team object that can have many Member objects. When I built my data model using Xcode, I was given the default NSSet in which to store the member objects, ...

Adding object to an NSMutableSet automatically when it's initiated... (iphone)

Hi ... I have this problem adding an object to NSSet... The NSMutableSet *set "belongs" to main ViewController. I want to add an object (Wall) to this NSMutableSet automatically if I add it to view in interface builder... Wall is a subclass of UIImageView... Thanks :) ...

NSPredicates with custom objects

Hi, I have the following problem and I cannot figure out how to solve it. I have an NSSet which contains Person objects (NSDictionary with 2 keys: name, age). From time to time I get an NSArray of Person objects and I want to add them to my NSSet but I want to filter out the duplicates. I'm thinking I could use NSPredicates but I am read...

NSArray from NSSet - Do I have to sort it myself?

I've got data in an NSSet, and I need to get it into an NSArray. Do I need to sort it myself (again, this came from Core Data) or can I get it out in a sorted order? ...

NSDictionary, NSArray, NSSet and efficiency

Hi, I've got a text file, with about 200,000 lines. Each line represents an object with multiple properties. I only search through one of the properties (the unique ID) of the objects. If the unique ID I'm looking for is the same as the current object's unique ID, I'm gonna read the rest of the object's values. Right now, each time I s...

displaying in a UITableView CoreData objects ordered in a Set

Hello, I have difficulties displaying objects coming from CoreData in a tableView. I have 2 sorts of entities : Sample and SampleList. What is important to know is that a SampleList has an attribute sampleSet which is a set of samples (entity of Sample) First I succeeded in displaying every SampleList. Here is viewDidLoad: NSFetchRequ...

Problems with NSSet (remove object and iterate)

Hi I am currently working on a project that uses CoreData and relations are using NSSet. I have currently 2 problems : How to iterate over an NSSet using an index ? --> SOLVED How to remove a specific object ? => I guess I need to iterate and check for the object ? hmm looks like I also have a problem adding an object ? Whats wrong ...

Problem with CoreData and accessing relationships : request for member in something not a structure or union

Hi I have a question regarding a rather advanced DataModel which I would like to use with CoreData. Before I get into details about what I did so far, I will describe what I want to do. I have a List of Hotel Guests that stay in one Room and have Preferences. Once ready the user should select a guest and see the data and should also b...

How to search an NSSet or NSArray for an object which has an specific value for an specific property?

How to search an NSSet or NSArray for an object which has an specific value for an specific property? Example: I have an NSSet with 20 objects, and every object has an type property. I want to get the first object which has [theObject.type isEqualToString:@"standard"]. I remember that it was possible to use predicates somehow for this ...

Subclassing/extending NSMutabelSet?

Hey, Is it possible to to subclass NSMutableSet? I need to do this in order to not retain objects contained in this set. The purpose todo that is to make an set of observers and those do not need to be retained. Is it possible to do this or maybe you have an another solution. Needles to say, I do know KVO but the pattern I have descri...