I'm new and this is my first post.
In my Inputstream I am getting list of message in where I have to filter a specific line and and to print that line, but some time its get crashed, can any one tell me where I'm making my mistake?
Here is my code:
NSMutableArray *substrings = [NSMutableArray new];
NSScanner *scanner = [NSScanner scannerWithString:s];
[scanner scanUpToString:@"&abc" intoString:nil]; //
NSString *substring = nil;
[scanner scanString:@"&abc" intoString:nil]; // Scan the # character
if([scanner scanUpToString:@"&" intoString:&substring]) {
// If the space immediately followed the &, this will be skipped
[substrings addObject:substring];
NSLog(@"substring is :%@",substring);
}
// do something with substrings
[substrings release];
I am getting:
&xyz;123:183:184:142&
&abc;134:534:435:432&
&qwe;323:535:234:532&
Sometimes I will get:
&qwe;323:535:234:532&
&abc;423:123:423:341&
&gfg;434:243:534:3434&
I want to print only string starts with "&abc" and ends with "&" ..
Is the code correct? Any suggestion?