---
title: "NSString indexOf in Objective-C"  
description: "NSString indexOf in Objective-C"  
author: "Anonymous User"  
published: 2015-09-07  
updated: 2015-09-08  
canonical: https://www.mindstick.com/forum/33444/nsstring-indexof-in-objective-c  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# NSString indexOf in Objective-C

Are there anything similar to an indexOf [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) in the NSString [objects](https://www.mindstick.com/forum/145447/what-are-objects)?

## Replies

### Reply by Tarun Kumar

If you want just know when String a contains String b use my way to do this.\
#define contains(str1, str2) ([str1 rangeOfString: str2 ].location != NSNotFound)

```
//using NSString a = @"PUC MINAS - BRAZIL";NSString b = @"BRAZIL";if( contains(a,b) ){    //TO DO HERE}
```


---

Original Source: https://www.mindstick.com/forum/33444/nsstring-indexof-in-objective-c

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
