Ios UICollectionView-异常“NSInvalidArgumentException”

Ios UICollectionView-异常“NSInvalidArgumentException”,ios,objective-c,xcode,uiviewcontroller,uicollectionview,Ios,Objective C,Xcode,Uiviewcontroller,Uicollectionview,我正在创建包含UICollectionView的UIViewController。这是故事板、代理和插座中的所有设置,我认为是正确的。在UIViewController中,我实现了以下方法: - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfI

我正在创建包含UICollectionView的UIViewController。这是故事板、代理和插座中的所有设置,我认为是正确的。在UIViewController中,我实现了以下方法:

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView 
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
除上述内容外,故事板还包括在单独类中定义的UICollectionViewCell。这一切工作正常,CollectionView按预期显示数据

但是。。。我希望创建一个单独的类来实现UICollectionViewDataSource、UICollectionViewDelegate方法,并且我已经将上面UIViewController类中的方法剪切并粘贴到一个单独的datasource类中。然后我将UICollectionViews委托和数据源设置为指向新类。这将导致以下异常:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'UICollectionView must be initialized with a non-nil layout parameter'
我已经尝试将新类作为NSObject添加到故事板中,并连接集合视图,还尝试以编程方式在ViewController中的ViewDidLoad方法中添加新类,但两者都有相同的异常。此外,在ViewDidLoad之前生成异常,ViewController是根视图控制器

如果我遗漏了什么,Google建议需要collection view initWithCollectionViewLayout,但是当CollectionView在故事板中初始化时,如何实现这一点?当它的方法在ViewController类中时,为什么它可以工作


最后一点是使用xCode 6 Beta 5,在一个完美的世界中,我会在xCode 5中尝试,但我正在将数据源迁移到Swift。

在所有键入之后,我发现这是一个愚蠢的输入错误,我将数据源类设为UICollectionView的子类,而不是NSObject