nsstring - Objective-C spaces in strings -
i have object called exampleobject
2 string properties: modulename
, , pool
.
@property (nonatomic, assign) nsstring *modulename; @property (nonatomic, assign) nsstring *pool;
both of these set using 2 text fields named modulenamefield
, poolfield
respectively, when ibaction triggered:
if (![[modulenamefield text] isequaltostring:@""]) { [[[appdelegate modulelist] objectatindex:[appdelegate modulenum]] setmodulename:[modulenamefield text]]; } if (![[poolfield text] isequaltostring:@""]) { [[[appdelegate modulelist] objectatindex:[appdelegate modulenum]] setpool:[poolfield text]]; }
after checking value nslog statement:
nslog(@"the modulename is:%@", [[[appdelegate modulelist] objectatindex:[appdelegate modulenum]] modulename]); nslog(@"the pool is:%@", [[[appdelegate modulelist] objectatindex:[appdelegate modulenum]] pool]);
i correct output:
the modulename is:module name 1 pool is:pool 1
here's gets weird. upon calling function of exampleobject
, try retrieve pool
, modulename
properties using:
nsstring *themodname = [nsstring stringwithformat:@"%@\n", [self modulename]]; nslog(@"the name is:%@",themodname); nsstring *thepool = [nsstring stringwithformat:@"%@\n", [self pool]]; nslog(@"the pool is:%@",thepool);
i'm able first log statement, prints:
the name is:module name 1
however, app crashes on nextline without error message. what's more interesting crashes when thepool
string spaces or mixed case. if rather "pool one", had made "poolone", not crash.
any insight appreciated!
it sounds memory issue , nsstring*
properties set assign. recommend setting them copy
or @ least retain
, making sure release them in dealloc method. since set assign messaging either 1 generate crash @ anytime, happens pool
in case.
Comments
Post a Comment