objective c - Problem with value of SIngleton in iPhone app -


When I try to print NSString in a textwave, I call my methods and the value of the string in the singleton class (invalid) (I have tested it with debug). Can you help me with code solutions?

My code:

  #import "unchecked viewer." #import "Singleton Controller." @Visual Controller @ Untitled Reset Synthesis Reset Taste Event; @ Synthesis buttonsweeppress; - (IBAction) ticket {textEvent.text = [name of shared controller]; } - (zero) viewDidoadload [[Super Viewedload]; Shared Controller = [Singleton Controller Shared Circulating Controller]; } - (zero) did the Reciever Memory Warning {// See if there is no Supervisor then it releases [Super Dareceywamari Warning]; // Use any cached data, images, etc. which are not in use. } - (zero) viewDidUnload {// Release main view of any maintained subviews // eg. Self.myOutlet = Zero; } - (zero) Delok [[Super Delooc]]; } @and # Imports "Singleton Controller. H" @ Application Singleton Controller @ synthesis name; Stable singleton controller * shared controller = zero; + (Singleton Controller *) Shared Circulating Controller {if (Shared Controller == Blue} {sharedController = [[Super Alok Woth Zone: NULL] init]; } Back share controller; } + (ID) allocWithZone: (NSZone *) area {return retained [[self-sharing simulation controller]]; } - (id) copywidth zone: (NSZEN *) area {returns self; } - retaining (id) {back self; } - (NSUInteger) retention number [Return NSUIntegerMax; // specifies an object that can not be issued} - (zero) release {// nothing} - (id) autoresz {return self; } - (id) init {self = [super init]; If (self! = Zero) {name = [NSString stringWithFormat: @ "hello"]; } Healthy return; } - (zero) Delok [[Super Delooc]]; } @end  

this line:

  name = [NSString stringWithFormat: @ "hello"];  

The problematic name refers to a frequency variable, not your property. So what is happening is that your string is being placed on the name , but it is an autoreled object. Therefore, at some point in the future, name is released automatically and it refers to the delocated memory.

If you have either specified the name property, keep retention or copy , then from the following lines Any item will retain the property:

  self.name = [NSString stringWithFormat: @ "hello"]; Name = [[[NSString stringWithFormat: @ "Hello"] maintained];  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -