【发布时间】:2013-07-16 08:58:35
【问题描述】:
我在运行我的应用程序时发现了一个信号 SIGABRT 线程。这是错误消息: [__NSCFConstantString _isResizable]:无法识别的选择器发送到实例 0x5c20
问题出在 [[self myCollectionView]setDataSource:self]; 因为当我评论它时它会消失。
据我了解,myCollectionView 数据源的类型和 self 不一样。这就是我有错误的原因。
感谢您的帮助
皮埃尔
CalViewController.h
#import <UIKit/UIKit.h>
@interface CalViewController : UIViewController <UICollectionViewDataSource, UICollectionViewDelegate>
@property (weak, nonatomic) IBOutlet UICollectionView *myCollectionView;
@end
CalViewController.m
#import "CalViewController.h"
#import "CustomCell.h"
@interface CalViewController ()
{
NSArray *arrayOfImages;
NSArray *arrayOfDescriptions;
}
@end
@implementation CalViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[[self myCollectionView]setDataSource:self];
[[self myCollectionView]setDelegate:self];
arrayOfImages = [[NSArray alloc]initWithObjects:@"chibre.jpg",nil];
arrayOfDescriptions =[[NSArray alloc]initWithObjects:@"Test",nil];
}
- (NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return [arrayOfDescriptions count];
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier=@"Cell";
CustomCell *cell = ([collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath]);
[[cell myImage]setImage:[arrayOfImages objectAtIndex:indexPath.item]];
[[cell myDescriptionLabel]setText:[arrayOfDescriptions objectAtIndex:indexPath.item]];
return cell;
}
- (NSInteger)numberOfSections:(UICollectionView *) collectionView
{return 1;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
【问题讨论】:
-
谢谢罗伯。现在可以使用了!
标签: ios string multithreading sigabrt