- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 restkit google 组中问过这个问题,但现在意识到它实际上可能是一个更广泛的问题,而不是特定于 RK 的问题。
我已经在这个问题上兜圈子几个小时了。我正在尝试使用从 Web 服务检索并使用 RestKits 对象映射存储在对象中的数据来填充 UITableView。调用服务、存储对象都非常完美。
问题是当我尝试为表重新加载数据时。我收到这个错误 -
'NSInvalidArgumentException', reason: '-[CoursesModel text]: unrecognized selector sent to instance and then app shuts down and
takes me here:
@autoreleasepool {
return UIApplicationMain(argc, argv, nil,
NSStringFromClass([RoundShoutAppDelegate class]));
}
Thread 1: signal SIGABRT
CoursesModel 是我设置的模型。如果我没有将 tableview 的委托(delegate)指定为类(我知道我必须这样做),那么类(class)将在 table view 中完美加载。但是,当我尝试单击其中一个单元格(在 didSelectRowAtIndexPath 处)时,我会收到错误消息。因此请关注事实上,我必须指定一个代表,我知道有些事情真的搞砸了,我无法弄清楚。
我假设有些东西在不应该发布的时候发布了,但数据在 _courses 数组中。顺便说一下,这是一个 ARC 项目。
这是一些相关的代码,但如果您需要更多,请告诉我。如果有人有任何信息可以指出我正确的方向,那就太棒了!感谢您的帮助!
MainViewController.h
@interface MainViewController : UITableViewController <CLLocationManagerDelegate, RKObjectLoaderDelegate, UITableViewDelegate, UITableViewDataSource> {
IBOutlet UITableView *coursesTableView;
NSArray *_courses;
}
@end
类(class)模型.h
@interface CoursesModel : NSObject {
NSNumber* _courseID;
NSString* _courseName;
NSString* _city;
NSString* _state;
NSNumber* _distance;
}
@property (nonatomic, retain) NSNumber* courseID;
@property (nonatomic, retain) NSString* courseName;
@property (nonatomic, retain) NSString* city;
@property (nonatomic, retain) NSString* state;
@property (nonatomic, retain) NSNumber* distance;
@end
主视图 Controller .m
//Most of the code ommited for your sanity
// All good up to this point
- (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:
(NSArray*)objects {
//NSLog(@"Loaded courses %@", objects);
_courses = objects;
// There is data in _courses.
NSLog(@"Loaded courses in array %@", _courses);
[coursesTableView reloadData];
委托(delegate)方法:
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { CGSize size = [[[_courses objectAtIndex:indexPath.row] text] sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:CGSizeMake(300, 9000)];
return size.height + 10;
}
最佳答案
我现在看到了!您的委托(delegate)方法
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
CGSize size = [[[_courses objectAtIndex:indexPath.row] text] sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:CGSizeMake(300, 9000)];
return size.height + 10;
}
错了。 NSArray 没有名为 -text 的方法,因此它导致将无法识别的选择器发送到 NSArray。为什么编译器没有就此警告您?如果您需要字符串,请使用 -stringValue
。
至于您的委托(delegate),这现在完全有意义,因为不设置委托(delegate)不会在重新加载时调用此方法。
关于objective-c - 无法识别的选择器发送到实例 - UITableView 和 Restkit LoadObjects 选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9848046/
我在通过拖放 session (使用 UICollectionView 's Drag&Drop feature)加载pdf文件时遇到问题。 在collectionView(_:performDrop
你好,可能是个简单的问题,每次我调用self loadObjects 来刷新tableview 中的对象时,它都会刷新很多次。 我 NSLog 一些对象以查看它加载了多少次,它会有所不同,有时我会加载
swift 我正在努力做到这一点,当您在 tableview 上拉动刷新时,它会使用存储在 Parse.com 上的数据更新 tableview 我已经研究过了,看来我需要使用 loadObjects
为什么该小程序要求使用烧烤渲染器?顺便说一下,我的烧烤 jar 似乎没问题,并且包含在同一文件夹中。 network: Cache entry not found [url: http://local
我在 restkit google 组中问过这个问题,但现在意识到它实际上可能是一个更广泛的问题,而不是特定于 RK 的问题。 我已经在这个问题上兜圈子几个小时了。我正在尝试使用从 Web 服务检索并
我愿意删除单元格并在PFQueryViewController的单元格中显示重载tableView。 但是,当我删除并刷新TableView时,出现错误:“***-[UITableView _endC
我是一名优秀的程序员,十分优秀!