I already googled for "CFString isNaturallyRTL" with 0 results.
these are my classes:
//in .H
@interface myVi开发者_JAVA百科ewController : 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;
[...]
}
}
Now, i have a view that open on button touch tha contains two text boxes and a button. Like this.
- (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];
}
It's all correct, compile and run.
First time that i click drawRouteTextboxes, it opens my view with default text setted ("Roma" and "lecce"). Second time, i open the view, edit textfield and call drawRoute. It's ok. The third time that i call drawRouteTextboxes it return me this runtime error:
*** -[CFString _isNaturallyRTL]: message sent to deallocated instance 0x3a8d140
I don't know where is the problem... Someone know a solution? It's the first time that i see this error!
thanks, Alberto.
It's all correct, compile and run.
If it was all correct, it would run without error. ;)
This looks suspect:
fromText = from.text; toText = to.text;
If from.text
and to.text
are returning either autoreleased objects or objects that are later released, then the above doesn't retain the strings and could easily lead to an over-release problem as you are seeing.
Use self.fromText = from.text;
instead.
Note that NSString*
properties should almost always be copy
and not retain
.
精彩评论