0
我有一个与我的服务器解析问题,特别是我添加的变量。它不允许我添加它。该错误信息是“错误的接收器类型‘布尔’(又名‘布尔’)”糟糕的接收器类型“布尔”
这里是我的代码:
@interface MessagingKeyServerResponse : NSObject <NSCopying>
@property (nonatomic, readonly) NSData *key;
@property (nonatomic, readonly) NSString *keyId;
@property (nonatomic, readonly) NSDate *validityStart;
@property (nonatomic, readonly) NSDate *validityEnd;
@property (nonatomic, readonly) BOOL support_long_messages;
@end
@interface MessagingKeyServerResponse()
// added support_long_messages for parsing
-(instancetype)initWithKey:(NSData *)key keyId:(NSString *)keyId validityStart:(NSDate *)validityStart validityEnd:(NSDate *)validityEnd support_long_messages:(BOOL)support_long_messages;
@end
NS_ASSUME_NONNULL_END
@implementation MessagingKeyServerResponse
// steve note: added message long characters
-(instancetype)initWithKey:(NSData *)key keyId:(NSString *)keyId validityStart:(NSDate *)validityStart validityEnd:(NSDate *)validityEnd support_long_messages:(BOOL)support_long_messages
{
if (!key) {
[NSException raise:NSInvalidArgumentException format:@"No key"];
return nil;
}
if (!keyId) {
[NSException raise:NSInvalidArgumentException format:@"No key id"];
return nil;
}
if (!validityStart) {
[NSException raise:NSInvalidArgumentException format:@"No validity start"];
return nil;
}
if (!validityEnd) {
[NSException raise:NSInvalidArgumentException format:@"No validity end"];
return nil;
}
if (!support_long_messages) {
[NSException raise:NSInvalidArgumentException format:@"there is no support long Characters"];
return nil;
}
if (!([validityStart compare:validityEnd] == NSOrderedAscending)) {
[NSException raise:NSInvalidArgumentException format:@"Invalid validity range"];
return nil;
}
self = [super init];
if (self) {
_key = [key copy];
_keyId = [keyId copy];
_validityStart = [validityStart copy];
_validityEnd = [validityEnd copy];
_support_long_messages = [support_long_messages copy] ;
if (!_key || !_keyId || !_validityStart || !_validityEnd || !_support_long_messages) {
return nil;
}
}
return self;
}
让我从_support_long_messages收到的时候我要分配的错误:
_support_long_messages = [support_long_messages copy];
任何帮助欣赏。
@property(nonatomic,assign)BOOL support_long_messages;尝试这个。 – phani
不,在我的功能不起作用,问题不是一个变量,它是一个参数,不在副本中分配。 – Steven