【发布时间】:2011-05-25 01:19:59
【问题描述】:
我写了以下代码:
if (depSelectedIndice > -1 && comSelectedIndice> -1)
{
NSLog(@"depart elemet : %d ",depSelectedIndice);
NSLog(@"depart elemet : %d ",comSelectedIndice);
NSLog(@"ok1");
NSString *choosedDate =[NSString stringWithFormat:@"%@%@",[deparatureDates objectAtIndex:depSelecif (depSelectedIndice > -1 && comSelectedIndice> -1)
{
NSLog(@"depart elemet : %d ",depSelectedIndice);
NSLog(@"depart elemet : %d ",comSelectedIndice);
NSLog(@"ok1");
NSString *choosedDate =[NSString stringWithFormat:@"%@%@",[deparatureDates objectAtIndex:depSelectedIndice], [goingBackDates objectAtIndex:comSelectedIndice]];
NSLog(@"0000000000001");
NSLog(@" number of element : %d", [allCombinations count]);
// for (int j=0; j<[allCombinations count]; j++)
// {
// NSLog(@"111111111111111111");
// // NSString *date = [[allCombinations objectAtIndex:j] objectForKey:@"keydate"];
// NSLog(@"22222222222222222222");
// if([date isEqualToString:choosedDate])
// {
// depPrice.text=@"1";
// comPrice.text=@"1";
// price.text=@"3";
//
// }
// }
}
allCombinations 是在.h 中声明的NSArray,我有 initilase 并在另一种方法中使用它。我不能在这种方法中使用? :/
但是我发生了崩溃。我真的不知道问题出在哪里,但我认为是当我比较if(date==choosedDate) 时?请帮忙
【问题讨论】:
-
当崩溃发生时你能添加你的堆栈跟踪吗?
-
@dredful @dredful @Chris 谢谢大家。我编辑了我的帖子。问题来自 allCombinations 。我在控制台中有 0000000000001。当我使 [allCombinations count] 时出现问题。控制台中没有错误将其发布到此处:( 请帮助
-
"allCombinations 是在 .h 中声明的 NSArray,我有 initilase 并在另一种方法中使用它。我不能在这种方法中使用?:/" - 你必须向我们展示代码/methods 与
allCombinations相关,因此我们可以查看您是否使用它做错了什么。
标签: objective-c iphone string nsstring comparison