Question

Je l'ai déjà googlé pour "CFString isNaturallyRTL" avec 0 résultats.

ce sont mes classes:

//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;
    [...]
  }
}

Maintenant, j'ai une vue qui ouvert sur tha tactile bouton contient deux zones de texte et un bouton. Comme cela.

- (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];
}

Il est tout correct, compiler et exécuter.

La première fois que je clique sur drawRouteTextboxes, il ouvre mon point de vue avec le texte par défaut setted ( « Roma » et « LECCE »). La deuxième fois, j'ouvre la vue, modifier et textfield appeler drawRoute. C'est bon. La troisième fois que je l'appelle drawRouteTextboxes il me renvoie cette erreur d'exécution:

*** -[CFString _isNaturallyRTL]: message sent to deallocated instance 0x3a8d140

Je ne sais pas où est le problème ... Quelqu'un sait une solution? Il est la première fois que je vois cette erreur!

Merci, Alberto.

Était-ce utile?

La solution

  

Il est tout correct, compiler et exécuter.

Si elle était correcte, il fonctionne sans erreur. ;)

Cela semble suspect:

fromText = from.text;   toText = to.text;

Si from.text et to.text retournent des objets soit autoreleased ou des objets qui sont libérés par la suite, le ci-dessus ne conserve pas les cordes et pourrait facilement conduire à un problème sur la libération que vous voyez.

Utilisez self.fromText = from.text; à la place.

Notez que les propriétés de NSString* devrait presque toujours être copy et non retain.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top