在我的应用程序中,我必须获取特定对象的索引值。为此我用这种方式编码,如下所示。
NSString *a=[NSString stringWithFormat:@"%d",[imagesdmobject.proofID intValue]];
NSLog(@"a value is %@",a);
这里的值是56
现在我必须从appdelegate.projectTitlesProofIDArray
得到56的索引。
int value=[appdelegate.projectTitlesProofIDArray indexOfObjectIdenticalTo:a];
<{1}}中的数据是:
41, 34, 35, 64, 45, 1, 67, 75, 76, 77, 78, 79, 80, 81, 82, 83, 85, 68, 86, 87, 88, 89, 90, 92, 69, 95, 97, 98, 100, 101, 70, 71, 72, 73, 74, 39, 37, 109, 108, 110, 38, 91, 93, 94, 36, 96, 99, 102, 103, 104, 105, 106, 107, 65, 66, 40, 46, 47, 48, 49, 50, 52, 53, 54, 60, 61, 62, 32, 55, 56, 57, 58, 59, 42, 43, 44, 63, 47, 48, 41, 34, 35, 64, 1, 91, 93, 94, 36, 96, 99, 102, 103, 104, 105, 106, 107, 65, 66, 40, 60, 61, 62, 32, 55, 56, 57, 58, 59, 54, 34, 35, 41, 34, 35, 64, 67, 75, 76, 77, 78, 79, 80, 81, 82, 83, 85, 68, 86, 87, 88, 89, 90, 92, 69, 95, 97, 98, 100, 101, 70, 71, 72, 73, 74, 39, 37, 109, 108, 110, 38, 91, 93, 94, 36, 96, 99, 102, 103, 104, 105, 106, 107, 65, 66, 40, 46, 47, 48, 49, 50, 52, 53, 54, 41, 34, 35, 64, 45, 1, 67, 75, 76, 77, 78, 79, 80, 81, 82, 83, 85, 68, 86, 87, 88, 89, 90, 92, 69, 95, 97, 98, 100, 101, 70, 71, 72, 73, 74, 39, 37, 109, 108, 110, 38, 91, 93, 94, 36, 96, 99, 102, 103, 104, 105, 106, 107, 65, 66, 40, 46, 47, 48, 49, 50, 52, 53, 54, 60, 61, 62, 32, 55, 56, 57, 58, 59, 42, 43, 44, 47, 34, 35, 39, 37, 109, 108, 110, 38, 46, 47, 48, 49, 50, 52, 53, 54, 42, 43, 44, 41, 34, 35, 64, 45, 1, 67, 75, 76, 77, 78, 79, 80, 81, 83, 85, 68, 86, 87, 88, 89, 90, 92, 69, 95, 97, 98, 100, 70, 71, 73, 74, 39, 37, 109, 108, 110, 38, 91, 94, 36, 96, 99, 102, 103, 104, 105, 106, 107, 65, 66, 40, 46, 47, 48, 49, 50, 52, 54, 60, 61, 62, 32, 55, 56, 57, 58, 59, 42, 43, 63, 41, 34, 35, 64, 45, 1, 67, 75, 76, 77, 78, 79, 80, 81, 82, 83, 85, 68, 86, 87, 88, 89, 90, 92, 69, 95, 97, 98, 100, 101, 70, 71, 72, 73, 74, 39, 37, 109, 108, 110, 38, 91, 93, 94, 36, 96, 99, 102, 103, 104, 105, 106, 107, 65, 66, 40, 46, 47, 48, 49, 50, 52, 53, 54, 60, 61, 62, 32, 55, 56, 57, 58, 59, 42, 43, 44, 63, 41, 34, 35, 64, 45, 1, 67, 75, 76, 77, 78, 79, 80, 81, 82, 83, 85, 68, 86, 87, 88, 89, 90, 92, 69, 95, 97, 98, 100, 101, 70, 71, 72, 73, 74, 39, 37, 109, 108, 110, 38, 91, 93, 94, 36, 96, 99, 102, 103, 104, 105, 106, 107, 65, 66, 40, 46, 47, 48, 49, 50, 52, 53, 54, 60, 61, 62, 32, 55, 56, 57, 58, 59, 42, 43, 44, 63, 46
56就在那里,但我得到的错误值为2147483647。
请帮我解决这个问题。我被困在这个地方。
答案 0 :(得分:0)
你需要这样做: -
假设您的数组包含: -
[array addObject:@"1"];
[array addObject:@"2"];
[array addObject:@"3"];
[array addObject:@"4"];
[array addObject:@"5"];
[array addObject:@"6"];
现在你需要找到对象5的索引
if([array containsObject:@"5"])
{
int index=[array indexOfObject:@"5"];
}