【发布时间】:2017-12-19 06:16:59
【问题描述】:
在 Objective-C 中自定义一个 iOS 应用。对语言不是很熟悉,设置布尔属性这个简单的任务花了我太长时间。
有人可以在这里提供一些建议吗?
视频.h
@property (nonatomic, retain) NSNumber * hasCustomThumbnail;
视频.m
@implementation Video
@dynamic hasCustomThumbnail;
@end
OtherFile引用视频
// have tried these two an many other things...
video.hasCustomThumbnail = [NSNumber numberWithBool:NO];
video.hasCustomThumbnail = @NO;
无论我尝试了多少种方法,我得到的错误是:
'NSInvalidArgumentException', reason: '-[Video setHasCustomThumbnail:]: unrecognized selector sent to instance 0x60c0004925c0'
尝试了很多建议,包括:Using a BOOL property
我也知道视频引用正确,因为在我开始输入时自动完成提示“hasCustomThumbnail”。
我简直不敢相信 OBJ-c 做这个有多难:-)
有什么建议吗?
【问题讨论】:
-
Video的超类是什么?Video是如何声明的? -
@alexr101 请检查我的答案。
-
Video是CoreData对象的表示吗?
标签: objective-c