• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSPredicate on sub array items?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSPredicate on sub array items?


  • Subject: NSPredicate on sub array items?
  • From: Trygve Inda <email@hidden>
  • Date: Fri, 17 May 2013 07:59:35 -0700
  • Thread-topic: NSPredicate on sub array items?

I have an NSArray managed by an NSArrayController (object class people) with
each people object containing an NSArray:

People[0]
Fistname (String) = John
Lastname (String) = Smith
Items (NSArray)
--Item[0] (String) = Boat
--Item[1] (String) = Car

People[1]
Fistname (String) = Bob
Lastname (String) = Jones
Items (NSArray)
--Item[0] (String) = Truck
--Item[1] (String) = Trailer
--Item[2] (String) = Boat

Is there a way, on the NSArray containing People objects, to create a
predicate that will find people with an item equal to "boat"

Or do I need to create a "calculated on the fly" field within people called
"OwnedItems" that would be built from the array and look like:

People[0]
Fistname (String) = "John"
Lastname (String) = "Smith"
Items (NSArray)
--Item[0] (String) = "Boat"
--Item[1] (String) = "Car"
OwnedItems (String) = "Boat,Car"

People[1]
Fistname (String) = "Bob"
Lastname (String) = "Jones"
Items (NSArray)
--Item[0] (String) = "Truck"
--Item[1] (String) = "Trailer"
--Item[2] (String) = "Boat"
OwnedItems (String) = "Truck,Trailer,Boat"

So that the predicate is searching at the same "level" as the rest of the
properties in the object? This method simply concatenates items together one
one line and inserts them as a separate key within each People object.

Ultimately, I'd like the "Items" to actually be stored in a common dict so
it might look like:

DictKey: 001 id:001 tag:Truck
DictKey: 002 id:002 tag:Trailer
DictKey: 003 id:003 tag:Boat
DictKey: 004 id:004 tag:Car

This way the Items Arrays would just have numbers (ids) that would refer to
another array of dicts to ge the actual item name.

This is to be able to apply "tags" to the People objects from a master list
of tags/items



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: CTFramesetterSuggestFrameSizeWithConstraints cuts off text
  • Next by Date: Re: CTFramesetterSuggestFrameSizeWithConstraints cuts off text
  • Previous by thread: Re: CTFramesetterSuggestFrameSizeWithConstraints cuts off text
  • Next by thread: Trigger nextkeyview based on NSTextField input length
  • Index(es):
    • Date
    • Thread