
RainbowString.h
#import <Foundation/Foundation.h>@interface RainbowString : NSMutableAttributedString@property (nonatomic) NSArray* colors;@property (nonatomic) NSTimeInterval duration;@property (nonatomic) NSTimer* timer;- (ID)initStringWithcolors:(NSArray*)colors withString:(Nsstring*)string;- (ID)initStringWithcolors:(NSArray*)colors withCycleDuration:(NSTimeInterval)duration withString:(Nsstring*)string;- (voID)stop;- (voID)start:(NSTimeInterval)duration;@end
initWithcolors:
- (ID)initStringWithcolors:(NSArray *)colors withString:(Nsstring *)string{ self = [super initWithString:string]; if(self) { [self setcolors:colors]; [self cycle]; } return self;} 即使我只是调用[[RainbowString alloc] initWithString:@“Hello”];,我得到同样的错误:
* Terminating app due to uncaught exception ‘NSinvalidargumentexception’,reason: ‘-[RainbowString initWithString:]: unrecognized selector sent to instance 0x166778c0’
更新
好吧,只是为了测试这个,我创建了一个NSMutableAttributedString的测试子类,绝对没有内容.我刚刚创建了子类并保持原样.
Test.h
#import <Foundation/Foundation.h>@interface Test : NSMutableAttributedString@end
我跑了:
[[NSMutableAttributedString alloc] initWithString:@"Hello"];
那跑得很好.但后来我跑了:
[[Test alloc] initWithString:@"Hello"];
同样的错误.我不允许继承NSMutableAttributedString或其他东西吗?
解决方法 你的结论是正确的. NS(Mutable)AttributedString是一个 class cluster,并且它们的子类化不起作用.遗憾的是,Apple文档并未将其明确标识为一个. 总结以上是内存溢出为你收集整理的ios – 子类化NSMutableAttributedString在init上返回SIGABRT全部内容,希望文章能够帮你解决ios – 子类化NSMutableAttributedString在init上返回SIGABRT所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)