I saw several examples related to using NSArray indexOfObjectPassingTest, but I could not get them to work (they will not return a valid index). So now I am trying to use the inline block. I did this by typing a block, then setting it as a property, synthesizing it and initializing it in the constructor. However, this view displays the entire point without sound, since I could easily create a method and use it instead (less typing, less effort).
What I'm trying to achieve is this:
Observations *obs = [self.myAppointment.OBSERVATIONS objectAtIndex: ^NSInteger (NSString *keyword){ for (Observations *obs in self.myAppointment.OBSERVATIONS) { if ([obs.TIME isEqualToString:keyword] == YES) return (NSInteger)[self.myAppointment.OBSERVATIONS indexOfObject:obs]; } return (NSInteger)-1; }];
However, Xcode simply will not have it. I tried different options, but declaring its embedded line seems to be a problem, which is strange because, as I said, typing it, declaring and synthesizing it works like this:
Observations *obs = [self.myAppointment.OBSERVATIONS objectAtIndex:findObs(keyword)];
Where findObs is again a specific block that does the same thing. Is this a syntax issue, or am I missing something even more important?
รlex source share