Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a following method to find index of a book object which have a book name:

+(NSInteger)indexXXX:(NSString *)bookName XXX:(NSArray *)books
  for (NSInteger i = 0; i < books.count; i++) {
    NSDictionary *book = [books objectAtIndex:i];
    if ([[book objectForKey:@"bookName"] isEqualToString:bookName]) {
      return i;
  return -1;

But I don't know what name should I use for this method.
Could you tell me some method names commonly used for this kind of method.

share|improve this question
up vote 4 down vote accepted

Usually we just name methods after what they do, so something like indexOfObjectWithName: inArray: would work.

To carry on past answering this question, the method can be made much simpler:

    NSArray *names = [books valueForKey: @"bookName"];
    return [names indexOfObject: bookName];
share|improve this answer
thanks for good answer. – js_ Aug 28 '12 at 11:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.