Wednesday, 29 May 2013

TO sort a string separated by symbols and make array of values




 NSString *string = @"0|0,0,0|0,0,0,0,0";  // Need to short 
    
    NSArray *myArray = [string componentsSeparatedByString:@"|"] ;
    
    NSArray *bookNoArray;
    NSArray *activityArray;
    NSArray *noOfPagesArray;
    for(int i=0;i<[myArray count];i++)
    {
        if(i==0)
        {
            bookNoArray= [myArray[i] componentsSeparatedByString:@","];
        }
        if(i==1)
        {
            activityArray= [myArray[i] componentsSeparatedByString:@","];
        }
        if(i==2)
        {
            noOfPagesArray= [myArray[i] componentsSeparatedByString:@","];
        }
        
    }
    NSLog(@"bookNoArray: %@ activityArray: %@ noOfPagesArray:%@ ", bookNoArray,activityArray,noOfPagesArray);       // Sorted out put