StationArray Class Reference
Inherits from | NSArray |
---|---|
Declared in | StationArray.h |
Overview
This is a simple subclass of NSArray that has methods to
assist with picking out stations based on metadata stored in their
options
attribute. See getStationWithOptions:
for the best
example.
– getStationWithOptionKey:Value:
Search through the stations in this array and return the one that has
an option attribute named key
with a value of value
(matched with
[value isEqual:entryValue]
or an array of values, one of which matches
value
.
- (Station *)getStationWithOptionKey:(NSString *)key Value:(NSObject *)value
Parameters
key |
name of attribute to inspect |
---|---|
value |
attribute value that matching station should contain |
Return Value
the first station with matching key/value pair or nil
Declared In
StationArray.h
– getStationWithOptionKey:
Search through the stations in this array and return the first one that has an option with the given key.
- (Station *)getStationWithOptionKey:(NSString *)key
Parameters
key |
name of attribute to search for |
---|
Return Value
the first station with an option attribute with the given key or nil
Declared In
StationArray.h
– getAllStationsWithOptionKey:
Search through the stations in this array and return all that have an option with the given key.
- (StationArray *)getAllStationsWithOptionKey:(NSString *)key
Parameters
key |
name of attribute to search for |
---|
Return Value
all stations with an option attribute with the given key. never nil.
Declared In
StationArray.h
– getStationWithOptions:
Search through the stations in this array and return one that has
options that match those passed in via optionKeysAndValues. This differs from
getStationWithOptionKey:Value:
in that you can specify multiple key/value
pairs.
- (Station *)getStationWithOptions:(NSDictionary *)optionKeysAndValues
Parameters
optionKeysAndValues |
key value pairs to search for |
---|
Return Value
the first station whose options contain optionKeysAndValues or nil
Discussion
This method returns the first station with the matching values, or nil.
A sample query might look like this:
[stations getStationWithOptions: @{ @"genre": @"80s", @"bpm" : @"slow" }
When run against stations with the following options values:
stationA.options = @{ @"genre": @"80s", @"bpm": @"fast" };
stationB.options = @{ @"genre": @"90s", @"bpm": @"slow" };
stationC.options = @{ @"genre": @"80s", @"bpm": @"slow", @"something": @"else" };
stationD.options = @{ @"genre": @"90s" };
this method would return stationC
.
When an option value is an array, this method will look for an element in the array that matches the search value.
The following station would match the query above:
stationE.options = @{ @"genre": @[ @"80s", @"hip-hop", @"rap" ], @"bpm": @"slow" };
Declared In
StationArray.h
– getAllStationsWithOptions:
Similar to getStationWithOptions:
, but this method returns all the stations
that match the passed in optionsKeysAndValues
rather than just the first.
- (StationArray *)getAllStationsWithOptions:(NSDictionary *)optionKeysAndValues
Parameters
optionKeysAndValues |
key value pairs to search for (see |
---|
Return Value
an array of stations whose options contain optionKeysAndValues. never nil.
Discussion
see getStationWithOptions:
for the format of optionsKeysAndValues
Declared In
StationArray.h
– getStationWithName:
Search the stations in this array and return the first one with the given name.
- (Station *)getStationWithName:(NSString *)name
Parameters
name |
name of station to look for |
---|
Return Value
the first station whose name matches
Declared In
StationArray.h