我完全迷失了,不知道如何甚至说出这个问题.我有一个循环,如下所示.如果if循环中的语句证明为true,indexPath则为其分配一个值,循环完成(_samplePictures数组中有49个对象)并输入if (found)然后加载找到的数据.如果条件不正确并且没有找到任何内容而不是进入if(!found)应用程序崩溃.我已经尝试了这种当前编码方案的各种结构.我甚至删除了循环并进入了if(!found)它应该做的事情.(ooooodddddddd)
此语句位于其viewDidLoad正上方(if语句不是viewDidLoad)是一个if确定内容的语句_samplePictures.
知道数组中的图像是这样定义的可能是有用的:
#define IMG_71 [UIImage imageNamed:@"imagename.jpg"]
Run Code Online (Sandbox Code Playgroud)
数组的结构是这样的:
_samplePictures = @[@{@"Image": IMG_71, @"Title" : @"title of item", @"Description" : @"complete description of item"}];
if (fromKitInstructions)
{
int i = 0;
NSIndexPath *indexPath;
found = FALSE;
while(i <= _samplePictures.count)
{
if([_samplePictures[i] objectForKey:@"Title"] == instructionName)
{
indexPath = [NSIndexPath indexPathForRow:i inSection:0];
i = 50;
found = TRUE;
}
else
{
i++; …Run Code Online (Sandbox Code Playgroud)