i know many solutions are available here for this problem but I am stuck on a single line which runs sometime successfully n crashes sometimes, i really dont know why this is happening.....
here is my code of posting mail in which i m getting the error -[__NSCFDictionary rangeOfString:]: unrecognized selector sent to instance
and here is my code of the method which is called on button pressed.
NSString* ingredientLine = [arrayOfIngredientList objectAtIndex:i];
NSArray* split ;
NSRange range = [ingredientLine rangeOfString:@"~"];
if (range.length > 0)
{
split = [ingredientLine componentsSeparatedByString:@"~"];
if( [split count] > 1 )
{
float amount = [[split objectAtIndex:0] floatValue];
float actualAmount = amount*((float)recipeServings/(float)4);
//parse the float if its 1.00 it becomes only 1
NSString* amnt = [NSString stringWithFormat:@"%.1f", actualAmount];
NSArray* temp = [amnt componentsSeparatedByString:@"."];
if([[temp objectAtIndex:1] isEqualToString: @"0"])
amnt = [temp objectAtIndex:0];
if( actualAmount == 0.0 )
amnt = @"";
[amnt stringByReplacingOccurrencesOfString:@".0" withString:@""];
NSLog(@"Amount is : %@",[split objectAtIndex:1]);
strAmount = [@"" stringByAppendingFormat:@"%@ %@",amnt,[split objectAtIndex:1]];
NSLog(@"Ingredient is : %@", strAmount);
strIngedient = [split objectAtIndex:2];
}
else //ingredients header
{
//[[cell viewWithTag:10] setHidden:YES];
strIngedient = [split objectAtIndex:0];
}
}
else
{
}
strIngredientsInfo = [strIngredientsInfo stringByAppendingFormat:@"%@ - %@ </br>",strAmount,strIngedient];
App crashes due to
NSArray* split ;
NSRange range = [ingredientLine rangeOfString:@"~"];
if (range.length > 0)
{
split = [ingredientLine componentsSeparatedByString:@"~"];
}
Please Help.
Please Suggest why it is crashing ???? :(