私は信じられないほど単純なことを成し遂げようとしています。コレクションビューの唯一のアイテムがプッシュされたときに、プログラムでviewControllerにプッシュしようとしています。何も起こりません。私のもつれた混乱には複数の問題があると思います。配列の基本についての私の理解は明らかに何でもありません。以下のifステートメント内にNSLog行を配置すると、1つのアイテムをプッシュしても何も得られません。これが私のdidSelectItemAtIndexPathメソッドです。
NSMutableArray *itemApp = [model.viewControllers objectAtIndex:indexPath.row];
if (itemApp == 0) {
NSLog (@"This does not appear")
TableViewController *ctc = [[TableViewController alloc] initWithStyle:UITableViewStylePlain];
[self.navigationController pushViewController:ctc animated:YES];
}
モデルはviewDidLoadで定義されています:
model = [[SimpleModel alloc] init];
SimpleModelは、.m実装で言及されています。
@implementation smileController;
{
SimpleModel *model;
}
viewControllersは、SimpleModelクラスのプロパティであり、その友人であるアプリとともに次のようになります。
@property (nonatomic, strong) NSMutableArray *apps;
@property (nonatomic, strong) NSMutableArray *viewControllers;
これがSimpleModel.mです
- (id)init
{
if (self = [super init])
{
self.apps = [NSMutableArray arrayWithObjects:@"1", nil];
self.viewControllers = [NSMutableArray arrayWithCapacity:self.apps.count];
TableViewController *tvc = [[TableViewController alloc] init];
[self.viewControllers addObject:tvc];
}
return self;
}