CFSTRING ISNaturallyRTL-发送到已交易实例的消息
-
09-10-2019 - |
题
我已经谷歌搜索了“ CFSTRING ISNaturallyRtl”,并获得了0个结果。
这些是我的课程:
//in .H
@interface myViewController : UIViewController {
UITextField *from;
UITextField *to;
NSString *fromText;
NSString *toText;
}
@property (nonatomic, retain) NSString* fromText;
@property (nonatomic, retain) NSString* toText;
@property (nonatomic, retain) UITextField *from;
@property (nonatomic, retain) UITextField *to;
//in .m
@synthesize from, to;
@synthesize fromText, toText;
viewDidLoad(...) {
fromText = @"Roma";
toText = @"Lecce";
}
- (void) drawRoute {
if ( ([[from text] length] > 2) && ([[to text] length] > 2) )
{
fromText = from.text;
toText = to.text;
[...]
}
}
现在,我有一个视图,即打开按钮触摸,包含两个文本框和一个按钮。像这样。
- (void) drawRouteTextboxes {
from = [[UITextField alloc] initWithFrame: [...] ];
from.text = fromText;
from.delegate = self;
[ctr.view addSubview:from];
[from release];
to = [[UITextField alloc] initWithFrame: [...] ];
[...]
[searchButton addTarget:self action:@selector(drawRoute) forControlEvents: UIControlEventTouchUpInside];
}
这都是正确的,编译和运行的。
第一次单击drawRouteTextbox,它使用默认文本设置(“ roma”和“ lecce”)打开我的视图。第二次,我打开视图,编辑TextField并调用DrawRoute。没关系。我第三次调用drawRouteTextbox,它返回我这个运行时错误:
*** -[CFString _isNaturallyRTL]: message sent to deallocated instance 0x3a8d140
我不知道问题在哪里...有人知道解决方案吗?这是我第一次看到这个错误!
谢谢,阿尔贝托。
解决方案
这都是正确的,编译和运行的。
如果一切都正确,它将在没有错误的情况下运行。 )
这看起来很怀疑:
fromText = from.text; totext = to.text;
如果 from.text
和 to.text
正在返回自我释放的对象或后来释放的对象,因此上面没有保留字符串,并且可以轻松地导致您看到的过度发行问题。
利用 self.fromText = from.text;
反而。
注意 NSString*
属性几乎应该 总是 是 copy
并不是 retain
.
不隶属于 StackOverflow