NSMutableArray *tempArr = [[NSMutableArray alloc] init];
if (self.subCategory) {
for (int i = 0; i < [self.subCategory count]; i++)
{
NSLog(@"subcat %@, detailItem %@",[[self.subCategory objectAtIndex:i] valueForKey:@"id_cat"],self.detailItem);
NSString *sub = [NSString stringWithFormat:@"%@",[[self.subCategory objectAtIndex:i] valueForKey:@"id_cat"]];
NSLog(@"What the result is %@",([sub isEqualToString:self.detailItem] ? @"Yes" : @"No"));
if([sub isEqualToString:self.detailItem])
{
NSLog(@"obj of subcat %@",[self.subCategory objectAtIndex:i]);
[tempArr addObject:[self.subCategory objectAtIndex:i]];
}
}
NSLog(@"tempArr %@",tempArr);
Почему этот код каждый раз дает этот вывод
2012-03-20 15:50:26.156 CameraFunWithFrames[1692:fb03] subcat 1, detailItem 1
2012-03-20 15:50:26.157 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.158 CameraFunWithFrames[1692:fb03] subcat 1, detailItem 1
2012-03-20 15:50:26.158 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.159 CameraFunWithFrames[1692:fb03] subcat 1, detailItem 1
2012-03-20 15:50:26.160 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.160 CameraFunWithFrames[1692:fb03] subcat 2, detailItem 1
2012-03-20 15:50:26.161 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.162 CameraFunWithFrames[1692:fb03] subcat 2, detailItem 1
2012-03-20 15:50:26.163 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.163 CameraFunWithFrames[1692:fb03] subcat 3, detailItem 1
2012-03-20 15:50:26.164 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.165 CameraFunWithFrames[1692:fb03] subcat 4, detailItem 1
2012-03-20 15:50:26.165 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.174 CameraFunWithFrames[1692:fb03] subcat 5, detailItem 1
2012-03-20 15:50:26.176 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.176 CameraFunWithFrames[1692:fb03] subcat 6, detailItem 1
2012-03-20 15:50:26.177 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.177 CameraFunWithFrames[1692:fb03] subcat 3, detailItem 1
2012-03-20 15:50:26.178 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.178 CameraFunWithFrames[1692:fb03] subcat 7, detailItem 1
2012-03-20 15:50:26.179 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.180 CameraFunWithFrames[1692:fb03] subcat 8, detailItem 1
2012-03-20 15:50:26.180 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.181 CameraFunWithFrames[1692:fb03] subcat 9, detailItem 1
2012-03-20 15:50:26.181 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.182 CameraFunWithFrames[1692:fb03] subcat 4, detailItem 1
2012-03-20 15:50:26.182 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.186 CameraFunWithFrames[1692:fb03] subcat 5, detailItem 1
2012-03-20 15:50:26.186 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.187 CameraFunWithFrames[1692:fb03] subcat 6, detailItem 1
2012-03-20 15:50:26.188 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.188 CameraFunWithFrames[1692:fb03] subcat 7, detailItem 1
2012-03-20 15:50:26.189 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.190 CameraFunWithFrames[1692:fb03] subcat 8, detailItem 1
2012-03-20 15:50:26.190 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.191 CameraFunWithFrames[1692:fb03] subcat 9, detailItem 1
2012-03-20 15:50:26.191 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.192 CameraFunWithFrames[1692:fb03] subcat 1, detailItem 1
2012-03-20 15:50:26.193 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.193 CameraFunWithFrames[1692:fb03] subcat 2, detailItem 1
2012-03-20 15:50:26.194 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.195 CameraFunWithFrames[1692:fb03] subcat 1, detailItem 1
2012-03-20 15:50:26.195 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.196 CameraFunWithFrames[1692:fb03] subcat 1, detailItem 1
2012-03-20 15:50:26.196 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.197 CameraFunWithFrames[1692:fb03] subcat 1, detailItem 1
2012-03-20 15:50:26.198 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.198 CameraFunWithFrames[1692:fb03] subcat 1, detailItem 1
2012-03-20 15:50:26.199 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.200 CameraFunWithFrames[1692:fb03] subcat 1, detailItem 1
2012-03-20 15:50:26.200 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.201 CameraFunWithFrames[1692:fb03] subcat 1, detailItem 1
2012-03-20 15:50:26.201 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.202 CameraFunWithFrames[1692:fb03] subcat 1, detailItem 1
2012-03-20 15:50:26.202 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.203 CameraFunWithFrames[1692:fb03] subcat 1, detailItem 1
2012-03-20 15:50:26.204 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.204 CameraFunWithFrames[1692:fb03] subcat 1, detailItem 1
2012-03-20 15:50:26.205 CameraFunWithFrames[1692:fb03] What the result is No
2012-03-20 15:50:26.205 CameraFunWithFrames[1692:fb03] tempArr (
)
, даже если это показывает, что subcat 1 и detailItem 1 оба являются nsstring, но не дает, если я сравниваю их, используя функцию isEqualToString, почему ??
что я должен сделать, чтобы решить эту проблему?
я использую xcode 4.3 и мое приложение использовало раскадровку вместо xib
он отлично работает с XIBS, как я использовал его до
Пожалуйста, помогите мне
Заранее спасибо.
РЕДАКТИРОВАТЬ :: Есть решение, спасибо всем, кто ответит на этот вопрос, спасибо всем вам
Я помещаю все данные в файл plist для ввода строки, так как они нужны мне в виде строки, прежде чем они нумеруются, особенно ключ id_cat.
По конверсии это дает неожиданные результаты.