// FileContent now holds ".... +option1 yourString +option2 ...."
int idx1 = [FileContent rangeOfString:@"+option1"].location;
int idx2 = [FileContent rangeOfString:@"+option2"].location;
int len2 = [@"+option2" length];
if ((idx1>=0)&&(idx2>=0)) {
NSString *str= [FileContent substringWithRange:NSMakeRange(idx1, idx2+len2-idx1)];
// now str holds "+option1 yourString +option2"
// split this into array
NSArray *arr = [str componentsSeparatedByString:@" "];
// now array arr has [+option1,yourString,+option2]
// So you can get your string by arr[1];
NSLog(@"MyString %@",arr[1]);
}
请注意,如果选项1和2的名称发生更改,或者它们的顺序发生了更改,则会中断。还要注意,我还没有测试这段代码。它可能在nsmakerange区域破裂。。。务必正确检查索引/长度。