拉胡尔,我想到了这一点,进一步开发和比较。这可能会帮助您:
NSString *characterstring=@"ASDFGFDSRFCGFRDHUJKIHTGRDFESERTGADERWFSGETWGHWGDHWDGWDGOHARHDKHRSGDGHSVDFHDJJDKSKWREFGHUJDMSJDHJGDGAFGREFGSDSGDHHDHAHDJSGAFDHWRODRGKDHDHDGRGFDCVEDDSGDGDHDHNDHJDJSHGD";
NSString *cmpString=@"WORK";
int s;
int p;
for (int j=0; j<cmpString.length; j++) {
for (int i=0; i<characterstring.length; i++) {
char b=[characterstring characterAtIndex:i];
if(b ==[cmpString characterAtIndex:j])
{
s=i;
}
if (j<cmpString.length-1) {
if(b ==[cmpString characterAtIndex:j+1])
{
p=i;
if (i+(p-s)<characterstring.length-1) {
if([characterstring characterAtIndex:i+(p-s)] ==[cmpString characterAtIndex:j])
{
p=i;
NSLog(@"[characterstring characterAtIndex:i+(p-s)]=%c",[characterstring characterAtIndex:i+(p-s)]);
}
}
NSLog(@"====%c",b);
}
}
}
}