0

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?

slm
  • 15,396
  • 12
  • 109
  • 124
Diaaaaan
  • 35
  • 6
  • @anoop vaidya where is the code ?? u deleted ? – Diaaaaan Apr 11 '13 at 14:19
  • yes after posting that i read you wanted to substring, not for full array filtering. – Anoop Vaidya Apr 11 '13 at 14:20
  • @AnoopVaidya i want to filter the string starts with &abc and ends with & – Diaaaaan Apr 11 '13 at 14:42
  • 1
    This is nothing to do with the `xcode IDE` please don't use that tag. Just because you are using `xcode` to develop in doesn't mean it's an `xcode` issue. The `xcode` tag is reserved for issues with the `xcode IDE` itself not issues that you are having with your code inside it. – Popeye Apr 12 '13 at 07:09

0 Answers0