pointer being freed was not allocated

今天在编写一个输入框中文字验证时,出现了以下的错误 JingDuTianXia(3422,0xa0c50540) malloc: *** error for object 0xb1e94: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug Program received signal: “SIGABRT”. 后来追查结果才发现是其中一个属性在一个方法中进行了字符串的赋值 - (int) checkAndSaveIn { self.loginName = @""; self.phone = @""; self.email = @""; self.loginCode = @""; self.secondLoginCode = @""; 而在dealloc方法中进行了内存释放 - (void)dealloc { [self.loginName release]; [self.phone release]; [self.email release]; [self.loginCode release]; [self.secondLoginCode release]; [self.registerTableView release]; [super dealloc]; } 而0xb1e94刚好就是@“”的值,所以是对@“”调用了release方法才导致了这个错误 另外发现类中的属性,在未设置值时,为nil。而UITextField类的text属性,在没有输入时,值也是nil text The text displayed by the text field. @property(nonatomic, copy) NSString *text Discussion This string is nil by default.

你可能感兴趣的:(free)