use*_*812 1 string iphone comparison objective-c nsstring
我写了以下代码:
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";
//
// }
// }
}
Run Code Online (Sandbox Code Playgroud)
allCombinations是NSArray在.h中声明的,我有initilase并在另一种方法中使用它.我不能在这种方法中使用?:/
但我崩溃了.我真的不知道问题在哪里,但我认为这是我比较的时候if(date==choosedDate)?请帮忙
dre*_*ful 23
当您使用==on指针时,NSString *它会比较内存地址,而不是比较字符串的值.
以下将实际比较字符串值:
if([date isEqualToString:choosedDate])
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17387 次 |
| 最近记录: |