I'm currently trying to get hold of my NSMutableArray
's index depending on one of it's object's properties.
I have an xml-structure such as this:
<timeperiod>
<Day>
<Date>20120325</Date>
</Day>
<Day>
<Date>20120326</Date>
</Day>
</timeperiod>
Now, imagine that the xml-structure contains every day in a month.
Day and all of it's properties are added to an NSMutableArray
.
And what i want is: To get the array's index depending on the date.
I'm imagining something like this in pseudo-code:
-(NSInteger)getIndexFromObjectProperty:(NSString *)property{
// Givf index from array where date is for example 20120310
//pseudo
Return [myClassObject.ObjectArray indexFromProperty:property];
}
I found this: Sorting NSMutableArray By Object's Property
This sorts from properties, but how to get an index from a property 0_0
I also found this: Function to get index from an array of objects having certain value of provided property Which would help alot if the syntax worked out of the box :(
Any tips and/or pointers will be highly appreciated.
Thanks in advance.
EDIT I'm currently trying the answers given. Will get back with an update.
EDIT2: Office is throwing me out since they're locking the building down... i'll get back to you tomorrow..